-
Notifications
You must be signed in to change notification settings - Fork 142
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
Respond to invalid api routes with JSON #11166 #11167
Conversation
@jacobtylerwalls I'm not sure how to test this. I can see that we now have an endpoint at "api", but how would this be used in practice? |
Sure thing. This came up in the controlled list manager work, where due to a bug the frontend was issuing malformed AJAX requests like:
So you can visit any invalid api route like |
|
I can't reproduce. Is there any additional information in the response? |
I can only get a response like that if I have DEBUG=False and a bad value in ALLOWED_HOSTS. But you don't need to test with DEBUG=False. Testing with DEBUG=True is easy because you can verify that you do not get the url debug view, but rather the route matches and returns JSON. |
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.
looks good! Thanks for the explanation @jacobtylerwalls !
Types of changes
Description of Change
A client might issue a malformed URL, e.g. api/controlledlists/1, which is malformed because 1 is not a UUID. It would be better for the server to respond with a JSON payload that could be parsed without additional effort. See screenshots on issue.
Issues Solved
Closes #11166
Checklist
Ticket Background