Skip to content

Promote R2 uploads through the S3 API - #31

Merged
AlexMikhalev merged 2 commits into
mainfrom
fix/promote-r2-s3-transport
Sep 25, 2026
Merged

AlexMikhalev merged 2 commits into
mainfrom
fix/promote-r2-s3-transport

Conversation

@AlexMikhalev

Copy link
Copy Markdown
Contributor

Problem

The first promote-release.yml dispatch (run 36185425648) failed with ERROR: uploaded R2 object is absent: terraphim-agent/terraphim-agent-1.21.16-aarch64-apple-darwin.tar.gz. Wrangler 4.140.0 r2 object put --remote printed "Upload complete." for the 8.4 MB archive in 1.35 s, but the public-URL readback 130 ms later returned 404 and the object never appeared. The 8 KB manifest objects uploaded and read back fine through the same path, which matches the wrangler remote-put reliability bug family (workers-sdk #12982, #13034, #6642) and Cloudflare's own guidance to prefer the S3 API for object transport.

Change

  • scripts/promote-release.sh: new r2_put helper routes every R2 write (immutable objects and the six stable pointers) through aws s3api put-object when R2_ENDPOINT, R2_ACCESS_KEY_ID, and R2_SECRET_ACCESS_KEY are exported, with wrangler kept as the fallback transport. Partial S3 credentials, non-HTTPS endpoints, or a missing aws binary fail closed before any remote query. Explicit content types mirror the previous wrangler behaviour. Every put keeps its existing immediate public-URL readback and byte comparison, so a transport that silently drops an object still aborts the promotion.
  • .github/workflows/promote-release.yml: the promote step now passes the existing R2_ENDPOINT, R2_ACCESS_KEY_ID, and R2_SECRET_ACCESS_KEY repo secrets, so Actions uses the S3 transport; wrangler stays installed for the fallback path.
  • tests/test_promotion_contract.py: an aws stub plus three contract tests - a full promotion through the S3 path with a poisoned wrangler (proving wrangler is never invoked) and an idempotent rerun, failure injection that must never advance stable manifests, and partial-credential rejection before any remote query. All 20 promotion contract tests pass.
  • docs/release-operator-checklist.md: documents both transports and the required environment variables.

Re-dispatching promote-release.yml for v1.21.16 after this merges is safe: the immutable preflight skips the two already-live manifest objects and all 21 byte-verified GitHub assets byte-for-byte.

Refs #337

Alex added 2 commits September 25, 2026 21:33
Wrangler 4.140.0 r2 object put --remote reported Upload complete. for the
8.4 MB v1.21.16 terraphim-agent archive, yet the object never became
readable through downloads.terraphim.ai while 8 KB manifests uploaded and
read back fine (workers-sdk issues #12982, #13034, #6642 family). Route
every R2 put through aws s3api put-object when R2_ENDPOINT,
R2_ACCESS_KEY_ID, and R2_SECRET_ACCESS_KEY are exported, keeping wrangler
as the fallback transport. promote-release.yml now passes the existing
R2_* repo secrets so Actions uses the S3 path; each put keeps its
immediate public-URL readback and byte comparison. Contract tests gain an
aws stub covering the transport, its failure semantics, idempotent rerun,
and partial-credential rejection. Refs #337
Hosted runners ship a real aws binary on PATH, so omitting the stub
cannot simulate its absence; the run reached the real client and failed
on connection instead of the command guard. The two partial-credential
subtests remain and exercise the same fail-closed guard block. Refs #337
@AlexMikhalev
AlexMikhalev merged commit ae2d5e9 into main Sep 25, 2026
2 checks passed
@AlexMikhalev
AlexMikhalev deleted the fix/promote-r2-s3-transport branch September 25, 2026 20:44
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