Skip to content
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

fix for #936 #937

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jwoytek
Copy link

@jwoytek jwoytek commented Mar 30, 2022

This is an attempt to fix the issue introduced with the release of Werkzeug 2.1, which no longer returns None when asked for JSON content on a request that does not have the Content-Type header set to "application/json".

Specifically, getattr() on line 125 in reqparse.py was looking for the default locations of json and values. This resulted in a call to json() in werkzeug.request, which in turn called get_json(). That method checks request.is_json, and now throws a BadRequest exception instead of returning None.

Here, I am proposing that flask-restful just perform the same check on request, and if the location is "json", skip it and move on.

@@ -122,6 +122,8 @@ def source(self, request):
else:
values = MultiDict()
for l in self.location:
if not request.is_json and l == 'json':

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching the order of these checks is probably more efficient.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Granted, re: your comment on the issue, this may be moot if maintenance has dropped off here, and we may need to look more closely at other options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants