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

Update pgstac to return 400 on invalid date parameter. #240

Merged
merged 5 commits into from Aug 20, 2021

Conversation

lossyrob
Copy link
Member

pgstac currently returns a 500 with an invalid date; this PR modifies this to return a 400.

Also allow backends to raise their own InvalidQueryParameter exceptions, which will be translated into a 400 by exception handling. This is another option for backends that want to handle query parameter validation in other ways besides stac-pydantic model validation.

This line in the pgstac search model indicates that validation is done outside of the pydantic model, but there were instances of asyncpg.exceptions.InvalidDatetimeFormatError being thrown for bad datetime parameters. We could solve this by removing the overridden validator, but I'm not sure why this was overridden and also I think it's useful to provide a non-pydantic mechanism for backends to indicate parameters are invalid and having stac-fastapi return the right status code.

Also allow backends to raise their own InvalidQueryParameter
exceptions, which will be translated into a 400 by exception
handling. This is another option for backends that want to handle
query parameter validation in other ways besides stac-pydantic model validation.
Copy link
Collaborator

@moradology moradology left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Removing a print statement that I assume was added in error and merging in changes on master. Once CI passes, I'll merge into master

@moradology moradology merged commit fa64c58 into master Aug 20, 2021
@moradology moradology deleted the fix/rde/invalid-date-400 branch September 23, 2021 17:43
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.

None yet

2 participants