When I use Flask-Restful in combination with the FlaskIntegration(), the SDK will report 405 Method Not Allowed and other HTTP-related exceptions to the server, even though we don't intend to. This issue does not occur with Flask's own MethodView or the regular function-based routes.
I consider this a bug in Flask-Restful. This is just a tracking issue for https://github.com/flask-restful/flask-restful/issues/802.
The workaround for this is to filter out http exceptions like any other exception:
from werkzeug.exceptions import HTTPException
def before_send(event, hint):
if 'exc_info' in hint:
exc_type, exc_value, tb = hint['exc_info']
if isinstance(exc_value, HTTPException):
return None
return event
sentry_sdk.init(before_send=before_send)
I'm hesitant in marking this as wontfix, we should probably ship a workaround for this if many people are affected. Sadly this would mean that there's no exact correlation between Flask's own notion of "unhandled exception" and ours.
A simpler workaround
from werkzeug.exceptions import HTTPException
sentry_sdk.init(
ignore_errors=[HTTPException], # workaround to ignore abort() on inside flask-restful
)
@bertonha We didn't stabilize ignore_errors yet, see #149. But yes, this is shorter and works too.
Most helpful comment
I'm hesitant in marking this as wontfix, we should probably ship a workaround for this if many people are affected. Sadly this would mean that there's no exact correlation between Flask's own notion of "unhandled exception" and ours.