Promote R2 uploads through the S3 API - #31
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The first
promote-release.ymldispatch (run 36185425648) failed withERROR: uploaded R2 object is absent: terraphim-agent/terraphim-agent-1.21.16-aarch64-apple-darwin.tar.gz. Wrangler 4.140.0r2 object put --remoteprinted "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: newr2_puthelper routes every R2 write (immutable objects and the six stable pointers) throughaws s3api put-objectwhenR2_ENDPOINT,R2_ACCESS_KEY_ID, andR2_SECRET_ACCESS_KEYare exported, with wrangler kept as the fallback transport. Partial S3 credentials, non-HTTPS endpoints, or a missingawsbinary 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 existingR2_ENDPOINT,R2_ACCESS_KEY_ID, andR2_SECRET_ACCESS_KEYrepo secrets, so Actions uses the S3 transport; wrangler stays installed for the fallback path.tests/test_promotion_contract.py: anawsstub 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.ymlfor 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