Skip to content

cold-store-reaper: curl fallback for GET-class S3 requests (LIST) after urllib exhaustion - #1625

Merged
dezren39 merged 2 commits into
mainfrom
cold-store-s3-list-curl-fallback
Oct 28, 2026
Merged

dezren39 merged 2 commits into
mainfrom
cold-store-s3-list-curl-fallback

Conversation

@dezren39

@dezren39 dezren39 commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Problem

Live 2026-10-28, twice (the nightly run and a manual retry): backup-supabase died at its first S3 GET — the bucket LIST — with

S3 GET supabase-backups failed after 4 attempts: transport error (IncompleteRead: IncompleteRead(24576 bytes read, 140424 more expected))

The sandbox egress proxy truncated urllib responses at varying offsets all night, and four consecutive whole-request retries all truncated. The existing curl fallback (PR #976) covers only s3_get_object's body download; _s3_request (LIST, and any other GET) had no fallback, so a hostile-proxy night kills backup-supabase and evict-scan before they start.

Fix

  • _s3_request: when the transport-retry loop exhausts AND the method is GET, make exactly one curl attempt for the same signed URL (_s3_request_via_curl) before raising. The curl response flows back in the same (status, headers, body) shape, so a 403/404 from curl surfaces through _s3_check exactly as a urllib error would — not as a transport failure.
  • Non-GET methods (DELETE) keep current behavior — no curl fallback.
  • s3_get_object passes curl_fallback=False: object downloads keep their dedicated byte-count-verified fallback in _s3_get_via_curl rather than this unverified one.
  • If curl also fails, the existing exhaustion ColdStoreError now notes the curl fallback was attempted. No credential material, no raw tracebacks.
  • Curl machinery generalized underneath _curl_fetch (its contract is unchanged): shared _curl_config / _curl_spawn / _curl_failure, plus _curl_fetch_status, which drops --fail and splits the HTTP status from the body via a --write-out trailer. Credentials still travel only in the stdin config and are scrubbed from every error.

Tests

Full suite: 86 tests OK (1 skipped = the node worker-decoder proof) — 80 pre-existing + 6 new. Object-GET fallback tests unchanged and passing.

New TestS3RequestCurlFallback:

  • LIST truncated on all 4 urllib attempts → curl returns the full XML, listing succeeds; curl invoked exactly once, only after exhaustion (fake's attempt counter snapshot); backup_supabase proceeds end to end on a fallback listing.
  • Curl fallback returning 403 → caller sees S3 list of supabase-backups failed (HTTP 403): Access Denied, not a transport error.
  • DELETE exhausting retries → no curl invocation, existing exhaustion error.
  • _curl_fetch_status trailer splitting + scrubbed transport failure, via stubbed subprocess.run.

One pre-existing test updated: TestS3TransportRetry.test_list_permanent_truncation_raises_named_error_after_4 — its scenario (permanent transport failure) is the one whose behavior this PR changes, so it now stubs the curl fallback to fail as well, keeps its 4-attempt/named-error assertions, and additionally asserts the error names the curl attempt.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Muse Sweep added 2 commits October 28, 2026 08:41
…ib exhaustion

The object-download curl fallback (s3_get_object) never helped the
bucket LIST: on 2026-10-28 every urllib attempt at the LIST truncated
at a different offset through the egress proxy, the transport retry
loop exhausted, and backup-supabase / evict-scan died at their first
S3 request. _s3_request now makes exactly one curl attempt for the
same URL when a GET's urllib attempts all fail at the transport
level, returning the usual (status, headers, body) shape so _s3_check
handles an HTTP error from curl exactly like one from urllib. Non-GET
methods get no fallback; s3_get_object opts out (curl_fallback=False)
and keeps its dedicated byte-count-verified fallback.

The curl machinery is generalized underneath _curl_fetch (whose
contract is unchanged): shared _curl_config/_curl_spawn/_curl_failure,
plus _curl_fetch_status, which drops --fail and splits the HTTP
status from the body via a --write-out trailer so error statuses
stay visible to callers. If curl also fails, the exhaustion error
says the fallback was attempted; credentials stay on stdin config
and scrubbed from all error text.
New TestS3RequestCurlFallback: LIST truncated on all 4 urllib
attempts falls back to curl exactly once (only after exhaustion) and
backup-supabase proceeds end to end; a curl 403 surfaces as the
standard _s3_check S3 error, not a transport error; DELETE
exhaustion never invokes curl; _curl_fetch_status trailer splitting
and scrubbed transport failures via stubbed subprocess.run.

TestS3TransportRetry's permanent-truncation LIST test now stubs the
curl fallback to fail too (its scenario is the one whose behavior
changed) and additionally asserts the exhaustion error names the
curl attempt; the object-GET fallback tests are unchanged.
@dezren39
dezren39 requested a review from a team as a code owner October 28, 2026 08:42
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9832f996-a463-411f-a338-c6ae2cb4094a
Commits

Reviewing files that changed from the base of the PR and between be7cf62 and 26fcb24.

Files selected for processing: 2
  • pkgs/cold-store-reaper/cold_store.py
  • pkgs/cold-store-reaper/tests/test_cold_store.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-28T08:42:36.495929Z 26fcb24 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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