thoth-station / user-api

Web Service exposing Thoth functions to the RESTful worlds
https://thoth-station.github.io/
GNU General Public License v3.0
8 stars 18 forks source link

sentry_sdk running along side flask throwing Bad Request #1769

Closed harshad16 closed 2 years ago

harshad16 commented 2 years ago

Describe the bug sentry_sdk running along side flask throwing Bad Request in user-api v0.35.2

Internal error in sentry_sdk
Traceback (most recent call last):
  File \"/opt/app-root/lib64/python3.8/site-packages/flask/wrappers.py\", line 128, in on_json_loading_failed
    return super().on_json_loading_failed(e)
  File \"/opt/app-root/lib64/python3.8/site-packages/werkzeug/wrappers/request.py\", line 611, in on_json_loading_failed
    raise BadRequest(
werkzeug.exceptions.BadRequest: 400 Bad Request: Did not attempt to load JSON data because the request Content-Type was not 'application/json'.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File \"/opt/app-root/lib64/python3.8/site-packages/sentry_sdk/integrations/flask.py\", line 192, in inner
    FlaskRequestExtractor(request).extract_into_event(event)
  File \"/opt/app-root/lib64/python3.8/site-packages/sentry_sdk/integrations/_wsgi_common.py\", line 72, in extract_into_event
    parsed_body = self.parsed_body()
  File \"/opt/app-root/lib64/python3.8/site-packages/sentry_sdk/integrations/_wsgi_common.py\", line 121, in parsed_body
    return self.json()
  File \"/opt/app-root/lib64/python3.8/site-packages/sentry_sdk/integrations/flask.py\", line 172, in json
    return self.request.get_json()
  File \"/opt/app-root/lib64/python3.8/site-packages/werkzeug/wrappers/request.py\", line 571, in get_json
    return self.on_json_loading_failed(None)
  File \"/opt/app-root/lib64/python3.8/site-packages/flask/wrappers.py\", line 133, in on_json_loading_failed
    raise BadRequest() from e
werkzeug.exceptions.BadRequest: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.

Additional context This is only happening in prod. user-api-17-44684-user-api.log

harshad16 commented 2 years ago

similar to: https://github.com/getsentry/sentry-python/issues/1459

harshad16 commented 2 years ago

This is not critical, it doesnt stops the functionality of user-api

mayaCostantini commented 2 years ago

/sig user-experience /priority important-soon

harshad16 commented 2 years ago

seems like the option is to downgrade the werkzeug. https://www.mail-archive.com/pgadmin-support@lists.postgresql.org/msg04310.html https://github.com/getsentry/sentry-python/issues/1459#issuecomment-1214131002 https://github.com/pallets/werkzeug/issues/2386#issuecomment-1097372801

harshad16 commented 2 years ago

Fixed with #1793 Already in production. Thanks to everyone.