Skip to content

Handle GitHub App token revocation connection errors#94

Draft
cursor[bot] wants to merge 1 commit intomainfrom
cursor/high-impact-sentry-errors-ee51
Draft

Handle GitHub App token revocation connection errors#94
cursor[bot] wants to merge 1 commit intomainfrom
cursor/high-impact-sentry-errors-ee51

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented Apr 22, 2026

Summary

  • Prevents ConnectionError during GitHub App token revocation from failing webhook processing.
  • Treats token revocation as best-effort cleanup in GithubAppToken.get_token().
  • Adds regression tests for revocation network failures and token-creation failures.

Root Cause

GithubAppToken.get_token() performed requests.delete() in a finally block without exception handling. When GitHub closed the connection during token revocation (RemoteDisconnected/ConnectionError), that cleanup exception escaped and bubbled up to the Flask handler, producing 500s and Sentry errors even when the main webhook handling path had succeeded.

Changes

  • Updated src/github_app.py:
    • Added module logger.
    • Wrapped revocation requests.delete() in try/except requests.RequestException.
    • Logs warning with context (installation_id) and traceback instead of raising.
  • Added tests/test_github_app.py:
    • Verifies revocation connection errors are ignored and only logged.
    • Verifies access-token creation errors still raise and no revocation attempt is made.

Validation

  • python3 -m pytest tests/test_github_app.py tests/test_web_app_handler.py
  • Result: 10 passed, 1 skipped.
Open in Web View Automation 

Co-authored-by: Armen Zambrano G. <armenzg@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant