Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stac-fastapi-core does not support configuring a STAC application with common extensions disabled #263

Open
sirosen opened this issue May 28, 2024 · 2 comments

Comments

@sirosen
Copy link

sirosen commented May 28, 2024

Describe the bug

When attempting to define a stac-fastapi-core-based application with the Query Extension disabled, I found that stac-fastapi-core would emit an attribute error and crashfail.
Specifically, the logic for handling a POST Search request here:

I found that this also happens with the sortby and token pagination extensions. Removing these makes the application inoperable.

To Reproduce

  1. Create a new application, e.g., based off of the mongodb example
  2. Remove the QueryExtension from the application's extensions
  3. Start the app (it will start)
  4. Send any valid POST Search
  5. 💥

Expected behavior

With Query disabled, searches should function.
The same holds for Sort and Token Pagination, but the case is clearest with Query (which is deprecated).

Additional context

I'm experimenting with building an application for my team, so I don't have a lot of knowledge around STAC. We're still learning the spec(s) and trying things out.
For now, we're trying to get a very early stage prototype up and running, so I've implemented this very clumsy hack:

class CustomizedCoreClient(CoreClient):
    async def post_search(self, search_request, request):
        object.__setattr__(search_request, "query", None)
        object.__setattr__(search_request, "sortby", None)
        object.__setattr__(search_request, "token", None)
        return await super().post_search(search_request, request)

I think the best pattern for the stac-fastapi-core code would be to check with hasattr(...) or three-argument getattr(..., ..., None).

I'm happy to contribute a PR with this sort of fix if it would be welcome.

@jonhealy1
Copy link
Collaborator

Hi thanks for bringing this to our attention. Feel free to make a pr. This should definitely be fixed.

@jamesfisher-geo
Copy link
Collaborator

I have been working on an adjacent issue and have added a condition for when an extension is enabled/disabled here #267. Maybe it is useful. Let me know if you have any suggestions for this approach.

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

No branches or pull requests

3 participants