question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flask-Restful: 405 method not allowed and other HTTP exceptions sent to server

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
untitakercommented, Mar 9, 2019

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.

2reactions
bertonhacommented, Apr 9, 2019

A simpler workaround

from werkzeug.exceptions import HTTPException

sentry_sdk.init(
    ignore_errors=[HTTPException],  # workaround to ignore abort() on inside flask-restful
)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Method Not Allowed flask error 405 - Stack Overflow
This is because you only allow POST requests when defining your route. When you visit /registrazione in your browser, it will do a...
Read more >
How to Fix the HTTP 405 Method Not Allowed Error - Kinsta®
A 404 tells you that the requested URL couldn't be found or that it was entered incorrectly. A 405 error message, on the...
Read more >
Avoiding the "405 Method Not Allowed" Error in Flask - YouTube
405 Method Not Allowed is a common error that beginners get while using Flask. In this video, I'll talk about why it happens...
Read more >
How to Fix HTTP Error 405 Method Not Allowed - Hostinger
The 405 Method Not Allowed error occurs between a client and a server. This message indicates that the web server has recognized a...
Read more >
405 Method Not Allowed: What It Is and How to Fix It
The user agent accidentally sent an incorrect HTTP method · The server is expecting only a handful of valid HTTP methods for the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found