geopython / pygeoapi

pygeoapi is a Python server implementation of the OGC API suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is open source and released under an MIT license.
https://pygeoapi.io
MIT License
499 stars 262 forks source link

pygeoapi allows the registration of invalid EDR queries #1773

Closed webb-ben closed 2 months ago

webb-ben commented 2 months ago

Description pygeoapi allows you to register any function to @BaseEDRProvider.register(), and will generate relative links for any edr provider that is registered. However when you try to navigate to the query itself, you receive an uninformative error - collection not found. This is because instead of finding the query, pygeoapi tries to find the collection that is named COLLECTON_NAME/EDR_QUERY_TYPE

Steps to Reproduce

  1. Create plugin with an EDR query that doesnt exist:

    @BaseEDRProvider.register()
    def location(self, **kwargs):
         pass
  2. Visit the collection page, and try to navigate to the offered EDR query

  3. View the error, collection not found. That is because it is looking for the collection named RISEEDR/location instead of the locaation query of the RISEEDR provider

Expected behavior pygeoapi does not allow the registration of invalid EDR query types, and throws an informative error when someone tries to register a query that is not valid.

Screenshots/Tracebacks image image

Environment

Additional context cc @C-Loftus

tomkralidis commented 2 months ago

This is rooted in pygeoapi defining the EDR routes (in Flask/etc.) explicitly. When a "foreign" query type is defined in an EDR provider (say foo) , Flask does not resolve the route, which causes Flask/pygeoapi to think the collection/foo is a hierarchical collection. It makes sense to constrain EDR providers, then, to bind to query types defined exclusively in the standard.