fix: use indexed bracket notation for multipart array encoding#90
Merged
fix: use indexed bracket notation for multipart array encoding#90
Conversation
…ices
The SDK's addFormValue uses `key + '[]'` for arrays, producing field
names like `files[][dest_path]` and `files[][file]` instead of
`files[0][dest_path]` and `files[0][file]`.
Without numeric indices, a server cannot:
1. Parse the field names (strconv.Atoi("") fails on empty brackets)
2. Pair file contents with their destination paths for multi-file uploads
These tests use a mock HTTP server with busboy to capture and inspect
the actual multipart field names the SDK produces. Affected endpoints:
- fs.upload (files array)
- browsers.loadExtensions (extensions array)
Made-with: Cursor
Changes array encoding in addFormValue from `key + '[]'` to
`key + '[' + i + ']'` so that arrays of objects produce indexed field
names (e.g. files[0][dest_path]) instead of ambiguous empty-bracket
names (e.g. files[][dest_path]).
Without indices, the server cannot parse the field names
(strconv.Atoi("") fails on the empty string between []) and cannot
pair file contents with destination paths for multi-file uploads.
Only two multipart endpoints have array-of-object fields:
- fs.upload (files array)
- browsers.loadExtensions (extensions array)
The other two multipart endpoints (deployments.create, extensions.upload)
have no array fields so are unaffected.
Updates the existing form.test.ts assertion to expect the correct
indexed format (bar[1] instead of bar[]).
Made-with: Cursor
0d41c2f to
e2a7664
Compare
sjmiller609
approved these changes
Mar 4, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
addFormValueuseskey + '[]'for arrays, producing field names likefiles[][dest_path]andfiles[][file]instead offiles[0][dest_path]andfiles[0][file].strconv.Atoi("")on the empty string between[]), returning 400 for all upload requests.Affected endpoints
Only two multipart endpoints have array-of-object fields and are affected:
fs.upload—files: Array<{dest_path, file}>browsers.loadExtensions—extensions: Array<{name, zip_file}>The other two multipart endpoints (
deployments.create,extensions.upload) have no array fields so are unaffected by this change.Fix
One-line change in
src/internal/uploads.ts:Failing tests added (commit 1)
fs.upload / single file should use indexed field names[0]fs.upload / multiple files should use distinct indexed field names[0],[1],[2]and content is correctly pairedfs.upload / field names should contain array indices (direct inspection)[]brackets, only numeric indicesbrowsers.loadExtensions / multiple extensions should use indexed field namesRepro
Test plan
form.test.tsto expectbar[1]instead ofbar[])./scripts/lint)