Prevent facets endpoint failure when facets are not configured - #1245
Open
Sanjays2402 wants to merge 1 commit into
Open
Prevent facets endpoint failure when facets are not configured#1245Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
The /collections/{collectionId}/facets endpoint read
config['repository']['facets'] directly, so a configuration without a
repository.facets entry raised KeyError: 'facets' instead of returning
a response.
API.__init__ already resolves the same setting with a default via
self.facets = self.config['repository'].get('facets', ['type']), so
facets_() now uses that attribute, matching the rest of the class.
Adds a regression test covering a config with no repository.facets.
Closes geopython#1240
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
API.facets_()readconfig['repository']['facets']directly, so a configuration without arepository.facetsentry raisedKeyError: 'facets'instead of returning a response.API.__init__already resolves the same setting with a default (self.facets = self.config['repository'].get('facets', ['type'])), sofacets_()now uses that attribute, matching the rest of the class.Related Issue / Discussion
Closes #1240
Additional Information
Regression test added to
tests/functionaltests/suites/oarec/test_oarec_functional.pynext totest_facets; it fails withKeyError: 'facets'without the change and passes with it. Fulltests/functionaltests/suites/oarec/suite: 18 passed.This change was prepared with AI assistance; the regression test was run locally and fails without the fix.
Contributions and Licensing
(as per https://github.com/geopython/pycsw/blob/master/CONTRIBUTING.rst#contributions-and-licensing)