On 2026-10-09 a tenant's managed Gitea was OOM-killed and restarted; six scheduled scans that cloned during the restart failed with Git error: unexpected http status code: 502.
What changes
New pipeline/git_retry.rs: Backoff (schedule 5 s, 15 s, 30 s) with retry(what, op), and is_transient(&git2::Error).
Not retried: ErrorCode::Auth (401), 403, 404, reference/repository errors, and AgentError::Other (so the GIT_CLONE_TIMEOUT_SECS / GIT_CLONE_MAX_MB limits never retry).
GitOps::clone_or_fetch retries the fetch of a cached entry (before the corruption fallback can mistake a 502 for a broken entry) and the atomic clone (which cleans its temp dir per attempt). Submodule fetches retry too. This covers every caller: orchestrator, PR review, ingest, graph and chat builds.
Each retry: WARN with attempt, wait_secs, error. The final error is returned unchanged, so callers log it as before.
The wait uses block_in_place on a multi-thread runtime, so the other tasks on that worker move elsewhere while it sleeps.
Tests
git_retry::tests: 502/503/500 transient; connection refused, timeout, unresolved transient; 401/403/404/missing ref/invalid URL/redirect not; fails twice then succeeds (3 runs); fails 4 times then errors (4 runs); permanent and limit errors run once; default schedule 5/15/30.
git::tests::a_clone_the_host_answers_with_502_is_tried_four_times: a local TCP server answering 502 sees exactly 4 requests and no checkout is left behind.
On 2026-10-09 a tenant's managed Gitea was OOM-killed and restarted; six scheduled scans that cloned during the restart failed with `Git error: unexpected http status code: 502`.
## What changes
- New `pipeline/git_retry.rs`: `Backoff` (schedule 5 s, 15 s, 30 s) with `retry(what, op)`, and `is_transient(&git2::Error)`.
- Retried: HTTP 5xx (`unexpected http status code: 5xx`), `ErrorCode::Timeout`, `ErrorClass::Net` (connect refused, resolve, socket read/write) except the URL errors (`invalid url`, `invalid scp-style path`, `cannot redirect`).
- Not retried: `ErrorCode::Auth` (401), 403, 404, reference/repository errors, and `AgentError::Other` (so the `GIT_CLONE_TIMEOUT_SECS` / `GIT_CLONE_MAX_MB` limits never retry).
- `GitOps::clone_or_fetch` retries the fetch of a cached entry (before the corruption fallback can mistake a 502 for a broken entry) and the atomic clone (which cleans its temp dir per attempt). Submodule fetches retry too. This covers every caller: orchestrator, PR review, ingest, graph and chat builds.
- Each retry: WARN with `attempt`, `wait_secs`, error. The final error is returned unchanged, so callers log it as before.
- The wait uses `block_in_place` on a multi-thread runtime, so the other tasks on that worker move elsewhere while it sleeps.
## Tests
- `git_retry::tests`: 502/503/500 transient; connection refused, timeout, unresolved transient; 401/403/404/missing ref/invalid URL/redirect not; fails twice then succeeds (3 runs); fails 4 times then errors (4 runs); permanent and limit errors run once; default schedule 5/15/30.
- `git::tests::a_clone_the_host_answers_with_502_is_tried_four_times`: a local TCP server answering 502 sees exactly 4 requests and no checkout is left behind.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
A git host that restarts answers 502 or refuses connections for a few
seconds, and every scan cloning in that window failed with "unexpected
http status code: 502". A clone, fetch or submodule fetch that fails with
a 5xx status, a timeout or a network error is now tried again after 5,
15 and 30 seconds. Authentication failures, 403, 404, bad references and
the download limits fail at once, as before. Each retry is logged at WARN
with the attempt and the wait; the wait hands the worker's other tasks to
another worker (block_in_place), so a waiting retry does not stall them.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
On 2026-10-09 a tenant's managed Gitea was OOM-killed and restarted; six scheduled scans that cloned during the restart failed with
Git error: unexpected http status code: 502.What changes
pipeline/git_retry.rs:Backoff(schedule 5 s, 15 s, 30 s) withretry(what, op), andis_transient(&git2::Error).unexpected http status code: 5xx),ErrorCode::Timeout,ErrorClass::Net(connect refused, resolve, socket read/write) except the URL errors (invalid url,invalid scp-style path,cannot redirect).ErrorCode::Auth(401), 403, 404, reference/repository errors, andAgentError::Other(so theGIT_CLONE_TIMEOUT_SECS/GIT_CLONE_MAX_MBlimits never retry).GitOps::clone_or_fetchretries the fetch of a cached entry (before the corruption fallback can mistake a 502 for a broken entry) and the atomic clone (which cleans its temp dir per attempt). Submodule fetches retry too. This covers every caller: orchestrator, PR review, ingest, graph and chat builds.attempt,wait_secs, error. The final error is returned unchanged, so callers log it as before.block_in_placeon a multi-thread runtime, so the other tasks on that worker move elsewhere while it sleeps.Tests
git_retry::tests: 502/503/500 transient; connection refused, timeout, unresolved transient; 401/403/404/missing ref/invalid URL/redirect not; fails twice then succeeds (3 runs); fails 4 times then errors (4 runs); permanent and limit errors run once; default schedule 5/15/30.git::tests::a_clone_the_host_answers_with_502_is_tried_four_times: a local TCP server answering 502 sees exactly 4 requests and no checkout is left behind.🤖 Generated with Claude Code
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p