Skip to content

fix EDR instances defaults returning rather than raising NotImplement… - #2478

Open
IanMayo wants to merge 1 commit into
geopython:masterfrom
IanMayo:fix/edr-instances-defaults
Open

IanMayo wants to merge 1 commit into
geopython:masterfrom
IanMayo:fix/edr-instances-defaults

Conversation

@IanMayo

@IanMayo IanMayo commented Nov 1, 2026

Copy link
Copy Markdown

fix EDR instances defaults returning rather than raising NotImplementedError (#2435)

Overview

BaseEDRProvider.instances() and instance() returned NotImplementedError() instead of raising it. For any provider that doesn't implement instances (including xarray-edr, and every other core EDR provider):

  • GET /collections/{id}/instances iterated an exception object → 500
  • GET /collections/{id}/instances/{anything} accepted any id
  • GET /collections/{id}/instances/{anything}/position?... served data, ignoring the instance (200 on master)

And for a provider that does implement instance(), returning False hit an UnboundLocalError in get_collection_edr_instances.

Changes:

  • API checks 'instances' in p.get_query_types() before calling either method: 404 on the instances routes, 400 (existing Invalid instance identifier) on an instance query
  • instance() returning False is treated as not found, per its documented bool contract; ProviderItemNotFoundError is still handled
  • base methods now raise NotImplementedError()

Related Issue / discussion

Part of #2435 (step 0 of the proposed sequence). This stands on its own and can be reviewed independently of the wider proposal.

Additional information

This differs from the approach sketched in #2435 (raising ProviderItemNotFoundError from the base class): honouring the documented return type is the smaller change, and the API never reaches the base defaults once it checks registration.

Tests: two added to tests/api/test_environmental_data_retrieval.py, both failing on master (ed4da5a) and passing here:

  • test_get_collection_edr_instances_unsupported — against icoads-sst (xarray-edr, no instances support): 404 on both instances routes, 400 on an instance query
  • test_get_collection_edr_instances_contract — against a stub provider implementing the documented contract: listing, a valid id, and an invalid id returning False → 404

The remaining EDR, API and coverages tests pass unchanged. tests/provider/test_sensorthings_edr_provider.py needs a live SensorThings server and fails identically with and without this change.

Dependency policy (RFC2)

  • I have ensured that this PR meets RFC2 requirements

No new dependencies.

Updates to public demo

No configuration changes needed. The demo's only EDR collection is icoads-sst (xarray-edr, which implements neither instances nor instance); no provider in core implements either method. Its behaviour changes from 500 / any-id-accepted / 200-ignoring-the-instance to 404 / 404 / 400 — exactly what test_get_collection_edr_instances_unsupported asserts against the same collection.

Contributions and licensing

(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)

  • I'd like to contribute a bugfix for EDR instance handling to pygeoapi. I confirm that my contributions to pygeoapi will be compatible with the pygeoapi license guidelines at the time of contribution
  • I have already previously agreed to the pygeoapi Contributions and Licensing Guidelines

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Human generated Label for the detect-ai workflow classifier

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant