Skip to content

Bug 2079908 - [GITHUB-ETL] Github-ETL should report errors to Sentry instead of exiting non-zero on partial failures - #22

Merged
dklawren merged 4 commits into
mainfrom
sentry-errors
Oct 9, 2026
Merged

dklawren merged 4 commits into
mainfrom
sentry-errors

Conversation

@dklawren

@dklawren dklawren commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Right now, when the GitHub ETL script hits an error on any repository (for
example, no access to a repo, or a GitHub/BigQuery error after retries), it
exits with a non-zero code. The Kubernetes CronJob pod then reports the whole
run as failed, even when the other repositories were processed and loaded
without problems.

Proposed change:

  • Add the sentry-sdk dependency and initialize Sentry when the SENTRY_DSN
    environment variable is set. If it isn't set, nothing changes, so local
    runs, docker-compose and tests behave as they do now.
  • Send each per-repository failure to Sentry with its full traceback, tagged
    with the repository name so it can be filtered in the Sentry UI. Warnings
    (retries, backoff) are attached to those events as breadcrumbs.
  • When some repositories fail, exit 0 so the cron pod no longer shows as
    failed. Sentry is where those failures get tracked.
  • Fatal errors still exit non-zero: missing required environment variables
    (GITHUB_REPOS, BIGQUERY_PROJECT, BIGQUERY_DATASET) and top-level
    RuntimeErrors. These are also sent to Sentry.
  • Flush pending Sentry events before the process exits so they aren't lost.

Deployment requirements:

  • A Sentry project for github-etl.
  • SENTRY_DSN added to the CronJob's secrets. SENTRY_ENVIRONMENT is optional.

Possible follow-up: Sentry Cron Monitors. Partial failures no longer fail the
pod, so check-ins would alert us if a scheduled run is missed or hangs.

…instead of exiting non-zero on partial failures
@dklawren
dklawren requested review from cgsheeh, shtrom and zzzeid and a balanced review from Copilot October 8, 2026 19:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Sentry reporting can expose credentials, loses worker-thread breadcrumbs, and suppresses failures when Sentry is unconfigured.

3 open findings
What changed in this PR

Adds Sentry reporting for repository-level ETL failures while allowing partial runs to succeed.

Changes:

  • Initializes Sentry conditionally and flushes events before exit.
  • Tags repository failures and changes partial-failure exit behavior.
  • Adds Sentry dependencies and tests.
File Description
main.py Adds Sentry reporting and revised exit handling.
tests/​test_main.py Tests Sentry setup and failure behavior.
pyproject.toml Declares the Sentry dependency.
requirements.txt Pins the Sentry dependency.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread main.py
Comment thread main.py Outdated
Comment thread main.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Exception messages can expose credentials to Sentry, and some failures generate duplicate events.

2 open findings
3 resolved since last review
Previously missed (2)

In code that hasn't changed since last review

Medium severity Verify repository failures are captured with tracebacks

tests/​test_main.py:636

This test verifies the scope tag and exit code, but not that the failure is actually sent with a traceback. Because sentry_sdk.init is mocked, LoggingIntegration is never installed; removing logger.exception would still leave this test passing. Exercise an in-memory Sentry transport or use explicit capture_exception and assert the captured exception and repo tag.

Medium severity Verify top-level RuntimeErrors are reported to Sentry

tests/​test_main.py:658

The PR also promises to report top-level RuntimeErrors, but this test checks only the return code and flush. With the SDK mocked, the logging integration is inactive, so the test passes even if no event is emitted. Add an assertion through an in-memory transport or switch to explicit capture_exception and assert that call.

🧠 Review effort: Balanced

Comment thread main.py
Comment thread main.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the described failure-handling behavior and has focused automated coverage.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

@shtrom shtrom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm; we could test the non-reporting of local variable thing a bit deeper (in fact, rather than just looking at the init options).

Comment thread tests/test_main.py Outdated
@dklawren
dklawren merged commit 122e3a9 into main Oct 9, 2026
5 checks passed
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.

3 participants