Skip to content

Prevent facets endpoint failure when facets are not configured - #1245

Open
Sanjays2402 wants to merge 1 commit into
geopython:masterfrom
Sanjays2402:fix/facets-not-configured
Open

Prevent facets endpoint failure when facets are not configured#1245
Sanjays2402 wants to merge 1 commit into
geopython:masterfrom
Sanjays2402:fix/facets-not-configured

Conversation

@Sanjays2402

Copy link
Copy Markdown

Overview

API.facets_() 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 (self.facets = self.config['repository'].get('facets', ['type'])), so facets_() 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.py next to test_facets; it fails with KeyError: 'facets' without the change and passes with it. Full tests/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)

  • I'd like to contribute bugfix prevent failure if config has no property facets #1240 to pycsw. I confirm that my contributions to pycsw will be compatible with the pycsw license guidelines at the time of contribution.
  • I have already previously agreed to the pycsw Contributions and Licensing Guidelines

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prevent failure if config has no property facets

1 participant