-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
AIP-84 Allow only positive limit and offset #44109
AIP-84 Allow only positive limit and offset #44109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a test for this?
I'll add a few to existing endpoints to verify the tests. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we don't have to do that ourselves, pydantic has a NonNegativeInt
which is equivalent to >= 0. Since FastAPI has a great integration with FastAPI, maybe just changing the type to NonNegativeInt
can make the trick, preventing us from adding custom code.
Also most likely, type error / validation error are by default 422 Validation Error and not 400. Just to stay consistant that might be converted to 422. (But if using native pydantic type, it will be automatically raised anyway).
f0ea194
to
32df34e
Compare
…AIP-84/limit_and_offset_filter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Wating for #44138 before merging. (This CI is shorter to run, and PR is easier to update if there are merge conflicts) |
* limit and offset can't be negative * add tests * refactor * use NonNegativeInt
As of now, OffsetFilter and LimitFilter allow the setting of negative values. With this PR, negative values will raise a 400 error.