Skip to content

Handle GitHub API timeouts when enriching workflow trace metadata#86

Draft
cursor[bot] wants to merge 1 commit intomainfrom
cursor/sentry-error-investigation-2e10
Draft

Handle GitHub API timeouts when enriching workflow trace metadata#86
cursor[bot] wants to merge 1 commit intomainfrom
cursor/sentry-error-investigation-2e10

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented Apr 19, 2026

Summary

This PR fixes a production failure path where transient GitHub API timeouts caused webhook processing to fail while building trace metadata.

Root Cause

GithubClient._get_extra_metadata() performed required network calls to GitHub (run_url and workflow_url) without handling requests timeout/connection exceptions. When GitHub timed out, the exception propagated to the Flask handler and produced 500 responses (Sentry issue SENTRY-GITHUB-ACTIONS-APP-6T).

Changes

  • Added a minimal metadata fallback in src/github_sdk.py so traces can still be generated when GitHub metadata fetch fails.
  • Wrapped GitHub metadata fetches with requests.RequestException handling:
    • If run metadata fetch fails, return fallback metadata and continue.
    • If workflow metadata fetch fails, continue without the workflow tag.
  • Added safe defaults and null filtering for optional metadata fields.
  • Added regression tests in tests/test_github_sdk.py for:
    • Timeout on run metadata fetch (fallback path).
    • Timeout on workflow metadata fetch (partial metadata path).

Validation

  • python3 -m pytest tests/test_github_sdk.py
  • Result: 9 passed

Risk

Low. The change only affects metadata enrichment and keeps existing behavior for successful GitHub API calls. In timeout scenarios, the app now degrades gracefully with reduced metadata rather than failing the webhook request.

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