Conversation
Each client of the file has a region, because the server checks it. This test keeps the default region of a client covered. It runs the client in a child process without S3_REGION and AWS_REGION, so the environment of the test does not change the result. The server refuses the signature, and its error names the region of the signature. The comment at withoutDefaultType names the pull request that has the correction for Bun.serve.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: oven-sh/bun/.coderabbit.yaml Review profile: ASSERTIVE Plan: Essentials Run ID: 📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review. WalkthroughThe changes add a subprocess test for S3 requests without a configured region and update a test-helper comment about a future removal. ChangesS3 region fallback test
S3 test helper note
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The new test checks that requests without a configured region use the expected signing region. No merge-blocking issue was identified. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
|
Status How I reproduced the problem:
How I verified the change:
|
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Beyond the inline findings, I also checked whether pinning the region auto certifies a bug rather than intended behavior: guess_region in src/s3_signing/credentials.rs:1115 deliberately returns auto for any explicit endpoint that is not amazonaws.com or R2, and the us-east-1 default that docs/runtime/s3.mdx:408 describes applies only when no endpoint is given, so the expected string matches the designed default for a custom endpoint.
Extended reasoning...
Test-only change: one new subprocess test in test/js/bun/s3/s3.test.ts against the local s3-server, plus a JSDoc note in test/packages/s3-server/test/helpers.ts; no src/ changes and no security-sensitive surface. The default-region value the test pins was traced to the non-AWS-endpoint branch of guess_region and is consistent with the docs' no-endpoint us-east-1 default, so it is not a snapshot of buggy behavior.
…ile is The child process had the directory of the test runner. A .env file there with AWS_REGION or S3_REGION gave the client that region. The child now runs in the temporary directory of the tests, and the names of the variables that it must not have are compared without their case. The test compares the complete error document of the presigned request, and it runs beside the other tests that start a process.
There was a problem hiding this comment.
LGTM — the second commit addresses each point from the earlier review, and the new test is hermetic and exact.
What was reviewed:
- Traced the expected strings against the local server:
signature.ts:233builds the region message withRegiondetail,credentialParameterErrorprefixes the X-Amz-Credential text, anderrorResponseemitsapplication/xmlwithRequestId(16 uppercase hex) andHostId(42 bytes base64 = 56 chars), matching the normalizing regex. - Checked the child spawn: pipes drained with
Promise.all,await using,cwd: testDir(a tempdir with onlyindex.mjs, so no dotenv file), and the region/session-token variables stripped case-insensitively from a spreadbunEnv. - The comment change in
helpers.tsis docs-only and links the upstream PR.
Extended reasoning...
The diff is test-only: one new it.concurrent test in test/js/bun/s3/s3.test.ts that spawns bun -e against the in-repo s3-server with no region configured and asserts the exact AuthorizationHeaderMalformed / AuthorizationQueryParametersError responses, plus a three-line doc comment in test/packages/s3-server/test/helpers.ts. It touches no runtime source and no security-sensitive surface; the only network traffic is to the local test server. The assertion strings and the RequestId/HostId regex were verified against the server's actual construction in signature.ts, context.ts and server.ts. The three optional comments from the prior run were all applied in commit 1c65f4e, no other reviewer has an open objection, and the changed files are not covered by CODEOWNERS.
Since the local server replaced the MinIO container, each test of the file runs under bun bd test. A debug build runs them many times slower than a release build. On a machine with a high load, three tests that move no data passed the default timeout of 5 seconds. CI does not run debug builds and passes --timeout to each test file.
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Beyond the inline note on the file-wide debug timeout, I re-checked the three points from the earlier round against the current diff and they are addressed: the child now runs with cwd: testDir so no dotenv file can supply a region, the presigned body is pinned to the full <Error> document with only RequestId/HostId normalized, and the test is it.concurrent like its siblings.
Extended reasoning...
Test-only change adding one subprocess test to test/js/bun/s3/s3.test.ts plus a docstring line in test/packages/s3-server/test/helpers.ts; it touches no src/ code and no security-sensitive surface. The earlier-round concerns (dotenv leakage via inherited cwd, substring-only body assertion, serial execution) are resolved in the code. The remaining inline finding is the isDebug-gated setDefaultTimeout(60_000), which conflicts with test/CLAUDE.md's rule against setting test timeouts, so a maintainer should weigh whether to keep it.
test/CLAUDE.md has the rule that a test sets no timeout. Three older tests of the file take more than 5 seconds under bun bd test on a machine with a high load. Pass --timeout to bun bd test on such a machine, as the CI runner does.
|
Updated 5:09 PM PT - Sep 28th, 2026
✅ @robobun, your commit 6c8c7215714e07d59508d86b76896fbbcb816ad6 passed in 🧪 To try this PR locally: bunx bun-pr 44110That installs a local version of the PR into your bun-44110 --bun |
There was a problem hiding this comment.
LGTM — the points from the earlier rounds are all addressed in the code now (child runs with cwd: testDir, the presigned 400 is pinned to the exact <Error> document with only the ids normalized, the test is it.concurrent, and the file-level setDefaultTimeout is gone).
What was reviewed:
- The id normalization regex against the server:
randomHex(8).toUpperCase()gives 16 hex chars and 42 random bytes in base64 give 56 unpadded chars, so the pattern matches every response. - Expected messages against
malformedHeader/credentialParameterErrorin test/packages/s3-server/src/signature.ts, and theautodefault in src/s3_signing/credentials.rs for a non-AWS endpoint. - Hermeticity: only the local s3-server is contacted, pipes are drained with
Promise.all, and stdout/stderr are asserted beforeexitCode.
Extended reasoning...
The diff adds one subprocess test to test/js/bun/s3/s3.test.ts that spawns bun -e without S3_REGION/AWS_REGION and asserts the local S3 server refuses read, write and presigned GET with region 'auto', plus a three-line doc comment in test/packages/s3-server/test/helpers.ts. No file under src/ changes and no security-sensitive surface is touched. Every objection raised in the three prior review rounds is visibly resolved in the current code, the assertions are exact and match the server implementation, and the changed files are not covered by CODEOWNERS, which decided approve.
…ckage The test is next to the test of a client with a wrong region now, and s3.test.ts is as on main. Under bun bd test on a machine with a high load, older tests of s3.test.ts pass the default timeout of 5 seconds, with and without this test.
There was a problem hiding this comment.
LGTM — the moved test now addresses everything raised earlier, and this revision is a self-contained, hermetic test-only change.
What was reviewed:
- The new test in test/packages/s3-server/test/server.test.ts: it runs in the concurrent describe, spawns the child in a fresh
tempDirso no dotenv file can supply a region, strips the region and session-token variables from a spreadbunEnv, drains stdout/stderr/exited together, and asserts one structured value covering both SDK errors and the full presigned<Error>document with only the per-request ids normalized (matchescredentialParameterErrorin src/signature.ts). - Cleanup ordering:
await using server,using dir,await using childare all declared before the assertions. - The
withoutDefaultTypechange in helpers.ts is a comment only; s3.test.ts and its debug-build timeout are no longer touched.
Extended reasoning...
The diff touches two files under test/packages/s3-server/test: a comment on withoutDefaultType in helpers.ts and one new test in server.test.ts that spawns bun -e against the in-repo mock S3 server to check that a client without a configured region signs for 'auto' and is refused by a region-enforcing server. No src/ code and no security-sensitive surface is affected; the test contacts only the local mock server. All inline concerns from earlier runs (dotenv leakage via cwd, substring assertion on the presigned body, serial execution, and the file-wide setDefaultTimeout in s3.test.ts) are resolved in the code itself by the move to the package's own test file, and there are no CODEOWNERS entries covering these paths. The bug hunt exited on dry_streak with no findings.
|
@robobun wake up!! |
|
@robobun wake up!! |
… of auth.test.ts auth.test.ts has the cases of a signature for a region that the server refuses. The test of a client without a region is one more of them. server.test.ts is as on main.
There was a problem hiding this comment.
LGTM — the moved test is hermetic and the points raised on earlier versions are addressed in the code as it now stands.
What was reviewed:
- The new test in test/packages/s3-server/test/auth.test.ts: child runs in an empty
tempDircwd with region/session variables filtered from a spreadbunEnv(harness vars such asBUN_DEBUG_QUIET_LOGSandPATHsurvive the filter), pipes are drained concurrently, stderr is asserted before the exit code, and the presigned 400 body is compared as a full<Error>document with onlyRequestId/HostIdnormalized. - The expected strings match the server's
signature.tserror text anderrors.tscodes;S3_*credentials set for the child take precedence over anyAWS_*values left in the environment. - Confirmed
test/packages/s3-server/test/*.test.tsis discovered by scripts/runner.node.ts, so the test runs in CI; no per-test timeout is added and no file undersrc/changes.
Extended reasoning...
The diff adds one test to the in-repo mock S3 server's auth tests and a two-line doc comment in helpers.ts; no runtime source is touched, so it has no user-facing or security-sensitive surface. The test spawns one bun -e child via bunExe/bunEnv against a local server, uses await using/using for cleanup, and asserts exact error codes, messages, status, content-type and bucket emptiness. Earlier inline feedback from this bot (missing cwd, substring-only XML check, non-concurrent placement, file-wide timeout) is reflected in the current code, and no CODEOWNERS entry covers the changed paths. The hunt ran dry with no findings and the change is small and self-contained, which decided approve.
|
Awake. The two red checks were not from the new test, and the branch has no conflict with main.
|
Behaviour change: none
Problem
test/js/bun/s3/s3.test.tshasregion: "us-east-1", because the local server checks the region of each signature. No test sends the default region of a client to a server that checks it.withoutDefaultType(test/packages/s3-server/test/helpers.ts:30) removes a header that only a debug build of Bun sends. Nothing in the package names server: don't send a fallback content-type on detached responses #30997, which correctsBun.serve, so the helper can stay after that correction.Fix
test/packages/s3-server/test/auth.test.ts. A client without a region reads, writes and presigns. The server has the regionus-east-1. It refuses each request, and its error names the region of the signature,auto.S3_REGIONandAWS_REGION, in a directory without a.envfile. The machine of the test runner does not change the result.withoutDefaultTypenames server: don't send a fallback content-type on detached responses #30997.bun bd test test/packages/s3-server/test/auth.test.tsand a release build, on Linux x64: each 149 pass, 0 fail.Background
S3_REGIONorAWS_REGION(src/dotenv/env_loader.rs:269). Without them,guess_region(src/s3_signing/credentials.rs:1115) reads it from the endpoint. For an endpoint that is not Amazon S3 or R2 the region isauto.auth.test.tshas the cases of a signature for a region that the server refuses. This test is one more of them, withBun.S3Clientas the client.s3.test.tsfor the test, and the client in the process of the test. The Notes have the reason against each.Notes
src/changes, so Bun behaves as before.S3_SESSION_TOKENand noAWS_SESSION_TOKEN. The error of the server isthe region 'auto' is wrong; expecting 'us-east-1'. The test compares the complete error document of the presigned request. OnlyRequestIdandHostIdare replaced before.AWS_REGIONandS3_REGIONin the environment of the test runner (on Windows also in lowercase, at the time when the test was inserver.test.ts), and with a.envfile that sets them in the directory of the test runner. With the client in the process of the test, or in a child process in the directory of the test runner, that.envfile made the test fail: the client signed forus-west-2.s3.test.ts: since test: replace the MinIO container with an S3 server on Bun.serve #44054 each test of that file runs underbun bd test, because the server needs no container. On my machine (load average 400 to 650) tests of that file pass the default timeout of 5 s in a debug build, with and without the new test. In 4 runs these wereshould be able to set content-typeof theBun.S3Clientgroup (2 runs), the 2 tests ofhttp endpoint should work when using env variables(3 runs), anddoes not UAF when a ReadableStream body errors after enqueue(1 run). With--timeout=270000, the per-test timeout of the ASAN lane, the file passes: 308 pass with the new test in it. A first form of this PR had the test there.server.test.ts. I did not run it there inauth.test.ts.server.test.ts. That file has 8 tests that start the server as a process. In a debug build on a machine with a high load, 5 of them took more than 60 s.auth.test.tsstarts no other process. The new test took 1.2 s and 7.2 s there underbun bd test.[auto-merge] gate passed · iteration 4 · 2 files touched
passes on PR (with fix)
diff hotspot
gate history · 2 passed · 3 rejected · iteration 4
evidence per changed file