-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ValueError for non-int limit and offset query params #1258
Conversation
* Add decorator that validates against a given schema * Add default_activity_list_schema * Refactor user_activity list to use validator decorator
change tests, no need to hit the database we only need to test that the vaildators raise a ValidationError
remove kwargs, otherwise the resulting action functions have the incorrect function signature
move validation out of action function and into the schema to prevent 500 errors
'convert_to_json_if_string' seems a bit ridiculous but I wanted to keep the logic the same and something like 'is_json' would be misleading. :( |
Review - all looks good. Well worth having all these improvements in. A few get functions remain without the validation still - group_package_show, tag_search, tag_autocomplete, but these can be done in the future. I'm handing off to @kindly and recommending it is merged. |
ValueError for non-int limit and offset query params
These lines obviously cause problems for non-int query params. This hit me as a 500 in production.
Since this is at least the third time for this kind of error to pop up, I'm strongly suggesting a proper pagination implementation to be used across resources. Something along the lines of:
There are many other places in
get.py
where this is a problem.