Skip to content

wrappers.py:129: BadRequest flask:2.0.3 #4508

Answered by davidism
HiroUkiFujii asked this question in Q&A
Discussion options

You must be logged in to vote
app/views/error_handler.py:18: in custom_client_error_handler
    current_app.logger.warning(exception, extra=dict(extra_data=to_extra_data()))
app/views/error_handler.py:46: in to_extra_data
    json_body=request.json,
/usr/local/lib/python3.8/site-packages/werkzeug/wrappers/request.py:540: in json
    return self.get_json()

Looks like you have a custom_client_error_handler method that calls to_extra_data for logging. That calls request.json unconditionally.

In pallets/werkzeug#2355, accessing json now raises a 400 error instead of returning None if the request is not well formed. You can use silent=True to make it return None instead, or you can use request.is_json instead to check if t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@HiroUkiFujii
Comment options

Answer selected by davidism
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants