-
Notifications
You must be signed in to change notification settings - Fork 6
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
InvalidRequestError: Invalid query produces an exception #9
Comments
Out of curiosity, could I see the source code? Also, what are you running as your web framework? Flask? Is Debug on? |
https://github.com/hroncok/utvsapi-ripozo Debug is on, do you want full traceback? |
|
Ah... It seems to be an issue with this line. It should be doing one of two things: Either ignoring fields not in the I'll try to get a fix out shortly (unless of course you want to jump on it). In the meantime, you can wrap it to get the correct response
|
A 400 response seems like a right thing to do. You could even do something like: try:
query = query.filter_by(**filters)
except InvalidRequestError as e:
field = str(e).split("'")[-2]
raise ValidationException(
'{} is not a valid filter on this resource.'.format(field)) |
It presents a certain security issue actually, people could theoretically query on fields that are not exposed to them. |
Well in that case can a pre check be run to see if the filter is fine? I'm not sure if that is OK either, because some fileds might get hidden in the postprocessor etc. |
Yeah, that's probably what I'll end up doing. I may simply add another property that defaults to |
Consider a following query:
If the column day exists, everything goes fine.
Now (day is an integer), the following query produces a nice JSON encoded error:
But if I try with non-existent column:
It blows an exception to the client.
The text was updated successfully, but these errors were encountered: