Binary ArrayBufferView slices send the entire backing buffer
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- api
Research direction
Start in src/core.ts:276 at methodRequest's conversion of non-DataView ArrayBufferView bodies. Reproduce the issue with the sliced Uint8Array example, then add regression coverage for sliced Uint8Array and Buffer values. Done means only the selected bytes are sent and the request body length is 2 bytes.
Written by the indexing model from the issue text.
Description
Description
Binary requests made with a sliced ArrayBufferView send the view's entire backing buffer instead of only the selected byte range.
methodRequest() converts non-DataView views with new DataView(opts.body.buffer) at src/core.ts:276. That drops the original view's byteOffset and byteLength. RequestOptions explicitly accepts ArrayBufferView, so callers can reasonably pass Buffer.subarray(), Uint8Array.subarray(), or another bounded view.
Reproduction
import Browserbase from '@browserbasehq/sdk';
let sentBody: any;
const client = new Browserbase({
apiKey: 'test',
maxRetries: 0,
fetch: async (_url, init) => {
sentBody = init?.body;
return new Response('{}', {
status: 200,
headers: { 'content-type': 'application/json' },
});
},
});
const backing = new Uint8Array([10, 20, 30, 40]);
await client.post('/binary', {
body: backing.subarray(1, 3),
__binaryRequest: true,
});
console.log(sentBody.byteLength); // 4, expected 2
console.log([...new Uint8Array(sentBody.buffer)]); // [10, 20, 30, 40]
Expected behavior
Only the selected bytes ([20, 30]) are sent, and the request body/content length is 2 bytes.
Actual behavior
All four bytes in the backing buffer are sent.
Why this matters
This corrupts binary payloads and can disclose adjacent bytes that the caller deliberately excluded with a view. The conversion should preserve byteOffset and byteLength, for example with new DataView(view.buffer, view.byteOffset, view.byteLength), and have regression coverage for sliced Uint8Array/Buffer values.
Tested against @browserbasehq/sdk 2.18.0 / current main (b781bd7).
- Dominant language
- TypeScript
- Stars
- 64
- Forks
- 17
- Avg merge
- 13m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from browserbase/sdk-node
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
browserbase/sdk-node#197 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
browserbase/sdk-node#193 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
browserbase/sdk-node#180 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 66/100
browserbase/sdk-node#218 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
browserbase/sdk-node#214 ·
All issues in browserbase/sdk-node
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·