fix(worker): Improve error handling for commit info updates#861
fix(worker): Improve error handling for commit info updates#861sentry[bot] wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 8be58bd. Configure here.
| except httpx.TimeoutException: | ||
| log.warning( | ||
| "Could not update commit with info because the request to the provider timed out" | ||
| ) | ||
| return False |
There was a problem hiding this comment.
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.


Fixes WORKER-Y8V. The issue was that: ReadTimeout from GitHub API unhandled;
possibly_update_commit_from_provider_infoonly catchesTorngitObjectNotFoundError, allowing network timeouts to escape.httpximport for timeout exception handling.TorngitClientErrorwhen updating commit information, logging a warning if the provider returns an error.httpx.TimeoutExceptionwhen 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
httpxtimeouts 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.