Skip to content

fix(worker): Improve error handling for commit info updates#861

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/torngit-error-handling
Open

fix(worker): Improve error handling for commit info updates#861
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/torngit-error-handling

Conversation

@sentry
Copy link
Copy Markdown
Contributor

@sentry sentry Bot commented Apr 19, 2026

Fixes WORKER-Y8V. The issue was that: ReadTimeout from GitHub API unhandled; possibly_update_commit_from_provider_info only catches TorngitObjectNotFoundError, allowing network timeouts to escape.

  • Added httpx import for timeout exception handling.
  • Implemented error handling for TorngitClientError when updating commit information, logging a warning if the provider returns an error.
  • Implemented error handling for httpx.TimeoutException when updating commit information, logging a warning if the request to the provider times out.

This fix was generated by Seer in Sentry, triggered automatically. 👁️ Run ID: 13537252

Not quite right? Click here to continue debugging with Seer.

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. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this 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.


Note

Low Risk
Low risk: adds explicit handling for provider client errors and httpx timeouts during commit info refresh, reducing unhandled exceptions but potentially masking transient failures behind warnings.

Overview
Improves worker resilience when backfilling commit metadata from git providers by catching additional failure modes in possibly_update_commit_from_provider_info.

Provider client failures (TorngitClientError) and request timeouts (httpx.TimeoutException) are now logged as warnings and treated as non-fatal, instead of bubbling up and failing the surrounding commit-update tasks.

Reviewed by Cursor Bugbot for commit 8be58bd. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8be58bd. Configure here.

log.warning(
"Could not update commit with info because the provider returned an error"
)
return False
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Swallowed exceptions prevent caller error tracking in breadcrumbs

Medium Severity

The new except TorngitClientError in possibly_update_commit_from_provider_info catches exceptions that the caller CommitUpdateTask.run_impl was specifically handling for error tracking. Since TorngitRepoNotFoundError is a subclass of TorngitClientError, it's now caught inside the function and silently returns False. The caller's except TorngitRepoNotFoundError and except TorngitClientError handlers in commit_update.py will never fire for provider errors, so _call_upload_breadcrumb_task is called with error=None instead of Errors.REPO_NOT_FOUND or Errors.GIT_CLIENT_ERROR, losing error observability.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8be58bd. Configure here.

Comment on lines +194 to +198
except httpx.TimeoutException:
log.warning(
"Could not update commit with info because the request to the provider timed out"
)
return False
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Bug: The new exception handler for httpx.TimeoutException will never be triggered. The torngit library converts this timeout into a TorngitServerUnreachableError, which remains unhandled.
Severity: CRITICAL

Suggested Fix

Replace the except httpx.TimeoutException: block with a handler for TorngitServerUnreachableError. This will correctly catch the actual exception raised by the torngit library during a provider timeout and prevent the task from crashing.

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: apps/worker/services/repository.py#L194-L198

Potential issue: The exception handler added to
`possibly_update_commit_from_provider_info` to catch timeouts is incorrect. It attempts
to catch `httpx.TimeoutException`, but the underlying `torngit` library intercepts this
specific exception and re-raises it as `TorngitServerUnreachableError`. Consequently,
the new `except httpx.TimeoutException:` block is dead code and will never be executed.
When a provider timeout actually occurs, the `TorngitServerUnreachableError` will be
raised and remain unhandled, causing the worker task to crash. The intended fix is
therefore ineffective.

Did we get this right? 👍 / 👎 to inform future reviews.

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.

0 participants