fix(repositories): Silence github errors when performing auto-sync#114650
Open
fix(repositories): Silence github errors when performing auto-sync#114650
Conversation
This more explicitly handles some github related errors and allows us to silence them Fixes SENTRY-5NAF
Comment on lines
224
to
234
|
|
||
| def is_broken_integration_error(self, exc: Exception) -> HaltReason | None: | ||
| if isinstance(exc, ApiForbiddenError) and "suspended" in str(exc): | ||
| return "installation_suspended" | ||
| if isinstance(exc, ApiForbiddenError): | ||
| if self.is_rate_limited_error(exc): | ||
| return "rate_limited" | ||
| if "suspended" in str(exc): | ||
| return "installation_suspended" | ||
| return "unauthorized" | ||
| return super().is_broken_integration_error(exc) | ||
|
|
||
| def message_from_error(self, exc: Exception) -> str: |
Contributor
There was a problem hiding this comment.
Bug: The ApiForbiddenError handling for repo auto-sync was not applied to GitHubEnterpriseIntegration, causing syncs to fail for GHE instead of silently halting on certain permission errors.
Severity: MEDIUM
Suggested Fix
Update GitHubEnterpriseIntegration.is_broken_integration_error in src/sentry/integrations/github_enterprise/integration.py to mirror the logic in GitHubIntegration.is_broken_integration_error. It should handle ApiForbiddenError by returning 'unauthorized' to ensure the sync process halts gracefully.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/sentry/integrations/github/integration.py#L223-L234
Potential issue: The fix to silently halt on `ApiForbiddenError` during repository
auto-sync was only applied to `GitHubIntegration` and not its counterpart,
`GitHubEnterpriseIntegration`. For GitHub Enterprise, an `ApiForbiddenError` that is not
related to a suspended account (e.g., an IP allowlist block) will not be correctly
handled by `is_broken_integration_error`. The error propagates up to `sync_repos.py`,
where it is re-raised, causing the sync process to fail for the integration instead of
being silently halted.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
This more explicitly handles some github related errors and allows us to silence them
Fixes SENTRY-5NAF