Skip to content

fix(integrations): Prevent ApiInvalidRequestError from creating Sentry issues#115535

Draft
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/integration-api-invalid-request-error
Draft

fix(integrations): Prevent ApiInvalidRequestError from creating Sentry issues#115535
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/integration-api-invalid-request-error

Conversation

@sentry
Copy link
Copy Markdown
Contributor

@sentry sentry Bot commented May 13, 2026

This PR addresses an issue where ApiInvalidRequestError exceptions, specifically those originating from the integration proxy returning a 400 Bad Request during GitHub get_rate_limit calls, were being captured as Sentry issues.

The SCMIntegrationInteractionEvent context manager, used in get_rate_limit, was configured to call record_failure(create_issue=True) for any unhandled exception. However, the _populate_trees function, which calls get_remaining_api_requests (which in turn calls get_rate_limit), already gracefully handles these exceptions by falling back to a cache.

To prevent excessive Sentry issue noise from these known and handled conditions, this change modifies IntegrationEventLifecycle.__exit__ to treat ApiInvalidRequestError as a halt rather than a failure. This mirrors the existing handling for RestrictedIPAddress exceptions. The event is still recorded as a halt in SLO metrics, ensuring visibility without generating unnecessary Sentry issues.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes SENTRY-5JQ5

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

Backend Test Failures

Failures on f02f3f8 in this run:

tests/sentry/integrations/github/tasks/test_link_all_repos.py::LinkAllReposTestCase::test_link_all_repos_api_errorlog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/integrations/github/tasks/test_link_all_repos.py:220: in test_link_all_repos_api_error
    assert end2.args[0] == EventLifecycleOutcome.FAILURE
E   AssertionError: assert <EventLifecycleOutcome.HALTED: 'HALTED'> == <EventLifecycleOutcome.FAILURE: 'FAILURE'>
E    +  where <EventLifecycleOutcome.FAILURE: 'FAILURE'> = EventLifecycleOutcome.FAILURE
tests/sentry/integrations/github/tasks/test_link_all_repos.py::LinkAllReposTestCase::test_link_all_repos_api_error_rate_limitedlog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/integrations/github/tasks/test_link_all_repos.py:248: in test_link_all_repos_api_error_rate_limited
    assert end2.args[0] == EventLifecycleOutcome.FAILURE
E   AssertionError: assert <EventLifecycleOutcome.HALTED: 'HALTED'> == <EventLifecycleOutcome.FAILURE: 'FAILURE'>
E    +  where <EventLifecycleOutcome.FAILURE: 'FAILURE'> = EventLifecycleOutcome.FAILURE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants