-
-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send request exception signal in common handler #1326
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RobbeSneyders
approved these changes
Jul 19, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx @Agalin!
hauntsaninja
pushed a commit
to hauntsaninja/connexion
that referenced
this pull request
Aug 10, 2022
* Send request exception signal in common handler * Sort imports Co-authored-by: Robbe Sneyders <[email protected]>
RobbeSneyders
pushed a commit
that referenced
this pull request
Dec 7, 2022
Fixes the problem of non-exceptional "exceptions" being recorded by telemetry systems as a serious error. This expands on the changes made in #1326. The intention of that other change seems to be making telemetry systems like Sentry record serious errors. Diving into the Sentry implementation even shows that the signalled exception is recorded at "level" = "error". The root of the problem is that exceptions are being used for control flow, which is not ideal - convenient for app writers but not always for library maintainers. The connexion BadRequestProblem and NotFoundProblem, for example, should not be recorded as an error in a telemetry system. In my case [elastic-apm-python](https://github.com/elastic/apm-agent-python) is receiving these signals and recording 4xx events as serious errors. This pull request only propagates an exception signal to flask if it's a serious error. Aiohttp applications have a similar problem with exceptions being used for control flow - the problems middleware will convert the exception into an appropriate problem response but things like the elastic apm python telemetry middleware will see that exception and record it as a serious error. Interestingly aiohttp also uses exceptions for control flow and the elastic apm agent was patched to specifically ignore aio web exceptions below the 5xx status response range. Elastic apm and sentry cannot be expected to be aware of non-serious control flow exceptions used by various libraries though. So, a solution for Aiohttp applications is a separate problem. Co-authored-by: Enerqi <>
RobbeSneyders
pushed a commit
that referenced
this pull request
Jan 24, 2023
Fixes the problem of non-exceptional "exceptions" being recorded by telemetry systems as a serious error. This expands on the changes made in #1326. The intention of that other change seems to be making telemetry systems like Sentry record serious errors. Diving into the Sentry implementation even shows that the signalled exception is recorded at "level" = "error". The root of the problem is that exceptions are being used for control flow, which is not ideal - convenient for app writers but not always for library maintainers. The connexion BadRequestProblem and NotFoundProblem, for example, should not be recorded as an error in a telemetry system. In my case [elastic-apm-python](https://github.com/elastic/apm-agent-python) is receiving these signals and recording 4xx events as serious errors. This pull request only propagates an exception signal to flask if it's a serious error. Aiohttp applications have a similar problem with exceptions being used for control flow - the problems middleware will convert the exception into an appropriate problem response but things like the elastic apm python telemetry middleware will see that exception and record it as a serious error. Interestingly aiohttp also uses exceptions for control flow and the elastic apm agent was patched to specifically ignore aio web exceptions below the 5xx status response range. Elastic apm and sentry cannot be expected to be aware of non-serious control flow exceptions used by various libraries though. So, a solution for Aiohttp applications is a separate problem. Co-authored-by: Enerqi <>
jcristau
added a commit
to jcristau/tooltool
that referenced
this pull request
Dec 18, 2023
spec-first/connexion#1326 changed FlaskApp.common_error_handler from a static method to a regular method, which means we can't use it without an actual FlaskApp, or we'd turn any error into a TypeError and 500. Fixes mozilla-releng#1159
jcristau
added a commit
to mozilla-releng/tooltool
that referenced
this pull request
Dec 20, 2023
spec-first/connexion#1326 changed FlaskApp.common_error_handler from a static method to a regular method, which means we can't use it without an actual FlaskApp, or we'd turn any error into a TypeError and 500. Fixes #1159
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Flask's default error handler sends
got_request_exception
signal (see this method). Handler provided byconnexion
doesn't do that and breaks integration of other apps, e.g. Sentry (see Flask integration implementation).Changes proposed in this pull request:
got_request_exception
signal incommon_exception_handler
registered for Flask application.got_request_exception
expecting an instancecommon_exception_hanndler
is changed from static method to a normal instance method.