-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix crash in S3 presign with missing credentials #28423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
f27681e
Fix crash in S3 presign with missing credentials
robobun f635d50
[autofix.ci] apply automated fixes
autofix-ci[bot] be69ab4
retry CI
robobun 9240986
Fix crash in S3 presign by computing URL without temporary blob
robobun ab261c9
[autofix.ci] apply automated fixes
autofix-ci[bot] 2fdb044
fix typo: greather -> greater
robobun d486956
fix path leak and s3:// prefix normalization in presignFromCredentials
robobun 1362929
retry CI
robobun 10d7d7a
add content_encoding to presignFromCredentials and stderr assertion t…
robobun a24c656
[autofix.ci] apply automated fixes
autofix-ci[bot] 3ee6137
add content_encoding to getPresignUrlFrom to match presignFromCredent…
robobun e584550
use idiomatic proc.stdout.text() in test
robobun 84e2ab9
[autofix.ci] apply automated fixes
autofix-ci[bot] 10860f2
strip leading slash after s3Path() to match Store.path() normalization
robobun 45f86de
remove strict stderr check that fails under ASAN
robobun 0b9bf69
[autofix.ci] apply automated fixes
autofix-ci[bot] 48826c8
retry CI
robobun c26bfda
retry CI - infra flake
robobun 43d7a33
retry CI
robobun be45713
Fix path leak: errdefer → defer for path cleanup in S3 functions
robobun 68b24aa
Revert errdefer→defer changes, keep stderr assertion
robobun 9276810
retry CI
robobun db30bb5
retry CI — prior build failures are infra (Darwin expired) and pre-ex…
robobun f8822f8
Add trailing backslash strip to match Store.S3.path() normalization
robobun c55e10c
retry CI
robobun 18e384f
retry CI
robobun ee54d4f
retry CI — prior infra outage
robobun 97b10aa
Fix sessionToken validation error message typo
robobun 7aa8f27
retry CI
robobun 1d6ccc2
retry CI
robobun cb81769
Fix S3Client.presign to not include acl/storage_class by default
robobun 914518d
Use client acl/storage_class as defaults only when options are provided
robobun bb780ee
retry CI
robobun 8ce8dee
retry CI
robobun 41e276d
retry CI
robobun d230939
retry gate check — prior failure was Docker container crash, not test…
robobun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { expect, test } from "bun:test"; | ||
| import { bunEnv, bunExe } from "harness"; | ||
|
|
||
| // Regression test: S3 presign with missing credentials should throw | ||
| // ERR_S3_MISSING_CREDENTIALS instead of crashing. | ||
|
|
||
| // Spawn subprocesses with S3 credential env vars explicitly unset so | ||
| // the tests are not affected by ambient AWS credentials in the host. | ||
| const cleanEnv = { | ||
| ...bunEnv, | ||
| AWS_ACCESS_KEY_ID: undefined, | ||
| AWS_SECRET_ACCESS_KEY: undefined, | ||
| S3_ACCESS_KEY_ID: undefined, | ||
| S3_SECRET_ACCESS_KEY: undefined, | ||
| AWS_SESSION_TOKEN: undefined, | ||
| S3_SESSION_TOKEN: undefined, | ||
| S3_ENDPOINT: undefined, | ||
| S3_BUCKET: undefined, | ||
| S3_REGION: undefined, | ||
| AWS_ENDPOINT: undefined, | ||
| AWS_BUCKET: undefined, | ||
| AWS_REGION: undefined, | ||
| }; | ||
|
|
||
| test("S3 presign with missing credentials throws instead of crashing", async () => { | ||
| await using proc = Bun.spawn({ | ||
| cmd: [ | ||
| bunExe(), | ||
| "-e", | ||
| ` | ||
| try { Bun.s3.presign("test-path"); } catch(e) { console.log(e.code); } | ||
| try { new Bun.S3Client().presign("test-path"); } catch(e) { console.log(e.code); } | ||
| try { Bun.S3Client.presign("test-path"); } catch(e) { console.log(e.code); } | ||
| Bun.gc(true); | ||
| console.log("ok"); | ||
| `, | ||
| ], | ||
| env: cleanEnv, | ||
| stdout: "pipe", | ||
| stderr: "pipe", | ||
| }); | ||
|
|
||
| const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]); | ||
|
|
||
| expect(stderr).not.toContain("error:"); | ||
| expect(stdout.trim()).toBe("ERR_S3_MISSING_CREDENTIALS\nERR_S3_MISSING_CREDENTIALS\nERR_S3_MISSING_CREDENTIALS\nok"); | ||
|
robobun marked this conversation as resolved.
|
||
| expect(exitCode).toBe(0); | ||
| }); | ||
|
claude[bot] marked this conversation as resolved.
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.