Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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.

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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.