-
Notifications
You must be signed in to change notification settings - Fork 4.7k
S3Client: don't double-deref path when a method fails after blob construction #30419
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
4 commits
Select commit
Hold shift + click to select a range
83c898a
S3Client.presign: don't double-deref path on sign error
robobun e2c0455
S3File: reuse parsed content_type instead of re-reading options.type
robobun c8149ec
S3Client: clear path handle after blob construction in all siblings
robobun a044067
ci: retrigger
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { expect, test } from "bun:test"; | ||
| import { bunEnv, bunExe } from "harness"; | ||
|
|
||
| // The path string's ref is transferred to the blob store; when the operation | ||
| // fails synchronously after that point the errdefer cleanup must not deref it | ||
| // a second time. | ||
| test("S3Client path methods throw instead of crashing on synchronous errors", async () => { | ||
| const env = { ...bunEnv }; | ||
| for (const k of [ | ||
| "S3_ACCESS_KEY_ID", | ||
| "S3_SECRET_ACCESS_KEY", | ||
| "S3_BUCKET", | ||
| "S3_ENDPOINT", | ||
| "S3_REGION", | ||
| "S3_SESSION_TOKEN", | ||
| "AWS_ACCESS_KEY_ID", | ||
| "AWS_SECRET_ACCESS_KEY", | ||
| "AWS_BUCKET", | ||
| "AWS_ENDPOINT", | ||
| "AWS_REGION", | ||
| "AWS_SESSION_TOKEN", | ||
| ]) { | ||
| delete env[k]; | ||
| } | ||
|
|
||
| await using proc = Bun.spawn({ | ||
| cmd: [ | ||
| bunExe(), | ||
| "-e", | ||
| ` | ||
| const out = []; | ||
| try { Bun.S3Client.presign("myfile"); } catch (e) { out.push(e.code); } | ||
| try { new Bun.S3Client({}).presign("myfile"); } catch (e) { out.push(e.code); } | ||
| try { Bun.S3Client.write("myfile", null); } catch (e) { out.push(e.code); } | ||
| try { new Bun.S3Client({}).write("myfile", null); } catch (e) { out.push(e.code); } | ||
| console.log(out.join(":")); | ||
| `, | ||
| ], | ||
| env, | ||
| stdout: "pipe", | ||
| stderr: "pipe", | ||
| }); | ||
|
|
||
| const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]); | ||
|
|
||
| expect(stderr).toBe(""); | ||
| expect(stdout.trim()).toBe( | ||
| "ERR_S3_MISSING_CREDENTIALS:ERR_S3_MISSING_CREDENTIALS:ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE", | ||
| ); | ||
| expect(exitCode).toBe(0); | ||
| }); |
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.