Skip to content

Comments

fix(nestjs-tools-fastify-upload): accumulate duplicate multipart field names into arrays#110

Merged
getlarge merged 2 commits intomainfrom
fix-multipart-duplicate-fields
Feb 3, 2026
Merged

fix(nestjs-tools-fastify-upload): accumulate duplicate multipart field names into arrays#110
getlarge merged 2 commits intomainfrom
fix-multipart-duplicate-fields

Conversation

@getlarge
Copy link
Owner

@getlarge getlarge commented Feb 3, 2026

Summary

Fixes #108

  • Duplicate non-file field names now accumulate into arrays instead of being overwritten
  • First occurrence stores as single value, second+ converts to array
  • Matches standard multipart parser behavior (Express, Multer, Busboy)

Changes

  • Add accumulateField() helper in body-accumulator.ts
  • Update all multipart handlers (single-file, multiple-files, any-files, file-fields) to use accumulator
  • Add comprehensive tests for duplicate field accumulation

Test Plan

  • Single field value remains string
  • Two duplicate fields become array [value1, value2]
  • Three+ duplicate fields accumulate correctly
  • All existing tests still pass (13/13)

🤖 Generated with Claude Code

getlarge and others added 2 commits February 3, 2026 09:26
…d names into arrays

Fixes #108

When multipart form-data requests contain duplicate field names (e.g.,
multiple `_owners` fields), the handler now properly accumulates them
into arrays instead of overwriting previous values with the last one.

Behavior:
- First occurrence: stores as single value
- Second occurrence: converts to array [first, second]
- Third+ occurrences: appends to existing array

This matches standard multipart parser behavior (Express, Multer, etc.)
and enables use cases like submitting multiple IDs or tags.

Changes:
- Add `accumulateField()` helper function in body-accumulator.ts
- Update all multipart handlers to use accumulator instead of direct assignment
- Add tests for duplicate field accumulation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@nx-cloud
Copy link

nx-cloud bot commented Feb 3, 2026

View your CI Pipeline Execution ↗ for commit 232a0cb

Command Status Duration Result
nx affected -t lint,test,build --parallel=2 ✅ Succeeded 4s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-03 08:40:53 UTC

@getlarge getlarge merged commit 2d6a0d4 into main Feb 3, 2026
6 of 7 checks passed
@getlarge getlarge deleted the fix-multipart-duplicate-fields branch February 3, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(fastify-upload): Multipart form-data array fields only receive last value

1 participant