fix(storage): bundle input and response#78
Conversation
Greptile SummaryThis PR refactors
Confidence Score: 4/5Safe to merge once the null-body guard is restored in the streaming path of One P1 finding: the removal of the
Important Files Changed
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Stream mode doesn't guard against null
response.body- Added a null-body guard in stream mode that returns an explicit error and covered it with a bundle test for a successful response with no body.
Or push these changes by commenting:
@cursor push d78b2062c4
Preview (d78b2062c4)
diff --git a/packages/storage/src/lib/object/bundle.test.ts b/packages/storage/src/lib/object/bundle.test.ts
--- a/packages/storage/src/lib/object/bundle.test.ts
+++ b/packages/storage/src/lib/object/bundle.test.ts
@@ -117,6 +117,30 @@
expect(result.data?.body.getReader).toBeDefined();
});
+ it('returns error when stream response has no body', async () => {
+ globalThis.fetch = vi.fn(async () => {
+ return new Response(null, {
+ status: 200,
+ headers: { 'content-type': 'application/x-tar' },
+ });
+ }) as typeof fetch;
+
+ const result = await bundle(['a.jpg'], {
+ config: {
+ bucket: 'my-bucket',
+ endpoint: 'https://test.endpoint.dev',
+ accessKeyId: 'test-key',
+ secretAccessKey: 'test-secret',
+ },
+ });
+
+ expect(result.error).toBeDefined();
+ expect(result.error?.message).toContain(
+ 'No body returned from stream request'
+ );
+ expect(result.data).toBeUndefined();
+ });
+
it('sends custom compression and error mode', async () => {
let capturedInit: RequestInit | undefined;
diff --git a/shared/http-client.ts b/shared/http-client.ts
--- a/shared/http-client.ts
+++ b/shared/http-client.ts
@@ -203,6 +203,14 @@
let data: TResponse;
if (req.stream) {
+ if (!response.body) {
+ return {
+ status: response.status,
+ statusText: response.statusText,
+ headers: response.headers,
+ error: new Error('No body returned from stream request'),
+ };
+ }
data = response.body as TResponse;
} else {
const contentType = response.headers.get('content-type');This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Add null check for response.body in HTTP client stream mode to prevent silent null propagation. Update bundle JSDoc to reflect current API signature. Assisted-by: Claude Opus 4.6 via Claude Code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit af65a3b. Configure here.
Prevents unhandled exceptions from network failures (DNS, timeout, etc.) by catching and returning errors using toError, matching the pattern used across the rest of the SDK. Assisted-by: Claude Opus 4.6 via Claude Code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🎉 This PR is included in version 2.16.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |


Note
Medium Risk
Medium risk due to a breaking
bundle()signature change and new streaming-path handling in the shared HTTP client, which could affect existing callers and error handling behavior.Overview
bundle()now takes onlykeysplus an options object (bucket comes fromoptions.config.bucketor global config) and routes requests throughcreateStorageClient()instead of manually building/singingfetchrequests.The shared HTTP client adds a
streammode to return the rawReadableStreambody (and error if missing), andbundle()surfaces client errors directly while returningbodyas a stream.Tests are updated to match the new API and to cover stream body success, missing-body errors, and updated error response parsing.
Reviewed by Cursor Bugbot for commit 8e6dc0d. Bugbot is set up for automated code reviews on this repo. Configure here.