fix(sentry): handle empty/non-JSON error responses in validate_scopes - #6813
Merged
shahargl merged 1 commit intoSep 13, 2026
Merged
Conversation
When Sentry returns an error with an empty or non-JSON body (e.g. HTTP 404 from
deprecated /plugins/webhooks/ on project:write), calling response.json()
raises requests.exceptions.JSONDecodeError. This unhandled exception bubbles up
and crashes the entire validate_scopes call, causing all scopes to report 'Not checked'.
Wrap error detail extraction in a helper that falls back to f'HTTP {response.status_code}'
if JSON decoding fails or detail is missing.
Fixes #6812
Contributor
|
🚀 Well done @apercivall! Two PRs merged already! 🎉🥳 With your second PR, you're on a roll, and your contributions are already making a difference. 🌟 |
This was referenced Sep 13, 2026
This file contains hidden or 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
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.
Summary
Safely extracts error details during Sentry
validate_scopesto prevent unhandledJSONDecodeErrorfrom crashing the entire validation check when Sentry returns an error response with an empty or non-JSON body.Fixes #6812
Problem
In
sentry_provider.py,validate_scopeschecks scopes (event:read,project:read,project:write).For
project:write, it sends aPOSTrequest to{sentry_api}/projects/{org}/{project}/plugins/webhooks/.When Sentry returns an error with an empty HTML body (e.g.
HTTP 404with 0 bytes, as the legacy/plugins/webhooks/API has been deprecated by Sentry), callingresponse.json()raisesrequests.exceptions.JSONDecodeError.Because this exception was unhandled:
validate_provider_scopesendpoint with an internal server error.event:readandproject:readwere fully valid and alerts were being ingested fine.Fix
Added a helper method
_extract_error_detail(response)that attempts to parseresponse.json().get("detail")or string representation, and cleanly falls back tof"HTTP {response.status_code}"if parsing fails. Applied across all error handling branches invalidate_scopes.