Handle exceeding the limit gracefully #2067
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Will now return a 400 to the user with info on what the limit was that caused the error.
Overview
Currently, if a user inputs a limit that exceeds the value in the
server.limits
configuration variable and the value ofon_exceed
iserror
, aRunimeError
will be returned. This is not ideal as it causes a 500 error to be returned to the user with no information on what caused it.Suggested fix in this pr:
Change from a
RuntimeError
to aValueError
, asValueError
is already being handled to ensure that the limit is a positive number. This will also return a 400 to the user, notifying them of the limit so they can adjust their queries.Related Issue / discussion
There is no existing issue for this. However, as it was a one line change, I consider it "trivial", and assume the discussion can happen here.
Dependency policy (RFC2)
Updates to public demo
Contributions and licensing
(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)