test: demonstrate multipart array encoding bug with arrayFmt:"comma"#86
Merged
test: demonstrate multipart array encoding bug with arrayFmt:"comma"#86
Conversation
The SDK's apiform.MarshalRoot hardcodes arrayFmt:"comma" which drops
array indices from multipart field names. For arrays of objects (like
the files array in /fs/upload or extensions in /browsers/{id}/extensions),
this produces ambiguous field names like "files.dest_path" and
"files.file" instead of "files.0.dest_path" and "files.0.file".
Without indices, a server cannot pair file contents with their
destination paths when multiple items are uploaded — all items share
identical field names.
These tests use httptest servers that attempt to decode the multipart
body using standard indexed field name parsing, demonstrating the
failure. Affected endpoints:
- BrowserFUploadParams (files array)
- BrowserLoadExtensionsParams (extensions array)
Made-with: Cursor
…rray encoding Changes arrayFmt from "comma" to "indices:dots" in MarshalRoot so that arrays of objects produce indexed field names (e.g. files.0.dest_path) instead of ambiguous repeated names (e.g. files.dest_path). This only affects the two MarshalMultipart callers that have array fields (BrowserFUploadParams, BrowserLoadExtensionsParams). The four callers without array fields are unaffected since the array encoder is never invoked. The objKeyEncoder also behaves identically for both formats (both use dot notation for nested objects). Made-with: Cursor
sjmiller609
approved these changes
Mar 3, 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
apiform.MarshalRoothardcodesarrayFmt:"comma"which drops array indices from multipart form field names. For endpoints with arrays of objects (like/fs/upload'sfilesarray), this produces ambiguous field names likefiles.dest_path/files.fileinstead offiles.0.dest_path/files.0.file.kernel browsers fs uploadreturning 400 in production: the server-side parser requires an indexed format but gets index-less field names.Failing tests added
TestUploadFilesMultipartEncoding/single_fileTestUploadFilesMultipartEncoding/multiple_filesTestUploadFilesFieldNameFormatTestLoadExtensionsMultipartEncodingRepro output
Two files uploaded, but all four field names are identical — no way to correlate which file goes with which dest_path.
Fix
The fix is to change
MarshalRootto usearrayFmt:"indices:dots"(or"indices:brackets") so it producesfiles.0.dest_path/files.0.file(orfiles[0].dest_path/files[0].file). Since this SDK is Stainless-generated, this likely needs a Stainless config change.Test plan
arrayFmtfix, all four tests should passNote
Medium Risk
Changes multipart form field naming for root-level arrays, which can affect server-side parsing expectations across upload-style endpoints. Risk is moderate because it alters request serialization but is covered by new integration-style tests.
Overview
Fixes multipart form encoding for root-level arrays by switching
apiform.MarshalRootfromarrayFmt:"comma"toarrayFmt:"indices:dots", ensuring fields are emitted as indexed names (e.g.,files.0.dest_path) instead of ambiguous repeated keys.Adds a new
multipart_array_encoding_test.gosuite that spins up anhttptestserver to parse incoming multipart requests and asserts thatBrowsers.Fs.UploadandBrowsers.LoadExtensionsproduce decodable, index-bearing field names for both single and multi-item arrays.Written by Cursor Bugbot for commit 11a7720. This will update automatically on new commits. Configure here.