feat(body)!: deliver array-typed and repeating form fields as arrays - #145
Open
line-o wants to merge 1 commit into
Open
feat(body)!: deliver array-typed and repeating form fields as arrays#145line-o wants to merge 1 commit into
line-o wants to merge 1 commit into
Conversation
Form-data and urlencoded body properties declared as type "array" in the requestBody schema, and repeating additional (schemaless) fields, are now wrapped in array(*) instead of being passed to handlers as XQuery sequences. This aligns $request?body with $request?parameters (parameters:cast-array already returns array(*) for multi-value parameters) and with JSON bodies, and makes the body map serializable with the JSON output method on eXist 7, which raises err:SERE0023 for sequences of more than one item as the serialization spec requires. BREAKING CHANGE: handlers reading multi-value form-data or urlencoded body fields must unpack an array now, e.g. $request?body?file?* instead of $request?body?file. Closes eeditiones#144 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L13cpTBpxHDuvVSd78BDQw
duncdrum
approved these changes
Sep 2, 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.
Implements Option 1 from #144: form-body values declared as
type: "array"— and repeating schemaless fields — are delivered to handlers asarray(*)instead of XQuery sequences.Why
eXist 7 made JSON serialization spec-compliant: the JSON output method now raises
err:SERE0023for a map entry whose value is a sequence of more than one item, where eXist ≤ 6.x silently coerced it to a JSON array. Any handler serializing$request?bodyfrom a form post with a repeating field therefore 500s on eXist 7 — this is what fails the two experimental CI jobs (existdb/existdb:latest/:release) onmain.Beyond the eXist 7 breakage, this fixes an internal inconsistency (see #144 comment):
parameters:cast-arrayalready returnsarray(*)for array-typed parameters, and JSON bodies naturally produce arrays — form bodies were the only place where the same declared schema type produced a sequence.Changes
content/body.xqmbody:validate-value: a property declaredtype: "array"is wrapped inarray { }when present (absent optional properties keep producing the empty sequence, matchingparameters:cast-array).body:additional-property(schemaless / undeclared fields): a repeating field is wrapped in an array; single values stay scalar (without a schema there is nothing that says "array").test/app/modules/upload.xqm:upload:batchunpacks the array ($request?body?file?*).doc/file-upload.md: batch examples updated accordingly.test/mediatype.test.js: new test posting a single file to the batch route — a declared-array property must be an array even with one value. The previously failing urlencoded tests pass unchanged, sinceserialize(map { …, "array": [1,2,3] }, map { "method": "json" })is valid on every eXist version.Breaking change
Handlers reading multi-value form-data/urlencoded body fields must unpack an array now (
$request?body?file?*instead of$request?body?file). Parameter handling and JSON bodies are unaffected — they were already arrays. The commit carries aBREAKING CHANGE:footer so semantic-release cuts a major version.Verification
Full suite run against both engines via Docker containers:
existdb/existdb:latest)main)The experimental CI jobs should go green with this change.
Closes #144
🤖 Generated with Claude Code
https://claude.ai/code/session_01L13cpTBpxHDuvVSd78BDQw