fix: don't send APIException (torngit auth errors) to Sentry #645
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
Fixes the #2 API error with ~1,400 events in 24 hours:
Root Cause
The
torngit_safedecorator catchesTorngitClientError(includingTorngitUnauthorizedError) and re-raises as DRFAPIException. In the GraphQLerror_formatter, exceptions are checked againstBaseExceptionorServiceException- if neither, they get sent to Sentry viacapture_exception.APIExceptionwasn't in this list, so all auth failures (expired tokens, revoked access, etc.) were being captured as errors.Fix
Add
APIExceptionto the list of expected exception types inerror_formatter. These represent client errors, not server bugs.Testing
Related Sentry Issues
Note
Treats DRF
APIExceptionas expected client errors in GraphQL error formatting, preventing Sentry noise from auth-related failures.APIExceptionimport and handling ingraphql_api/views.py:error_formatter; setsmessagefromdetailandtype, and skipscapture_exceptionBaseException/ServiceException; unexpected errors still logged and sent to SentryWritten by Cursor Bugbot for commit e180cb5. This will update automatically on new commits. Configure here.