Skip to content

test: expect Node-style aggregation of multi-value request headers - #324

Open
mcollina wants to merge 1 commit into
mainfrom
fix/base64-post
Open

mcollina wants to merge 1 commit into
mainfrom
fix/base64-post

Conversation

@mcollina

@mcollina mcollina commented Dec 2, 2026

Copy link
Copy Markdown
Member

Root cause

test/basic.test.js › POST with base64 encoding has been failing on every CI run since mid-October (500 == 200 at test/basic.test.js:466), on all Node versions and OSes. The 500 does not come from the base64 body handling. It comes from an assert inside the route handler that throws and is turned into a 500 by Fastify's default error handler. The assertion that throws is on the x-multi header, which the test builds from the event's multiValueHeaders:

expected: 'just-the-first,and-the-second'
actual:   'just-the-first, and-the-second'

This library passes multi-value headers to app.inject() as an array. light-my-request used to stringify array header values with '' + value, which joins them with a bare ,. Since light-my-request 6.8.0 (fastify/light-my-request#388, commit fastify/light-my-request@627c890, release notes), array header values are aggregated the same way Node's HTTP server combines repeated header lines: ', ' for most headers, '; ' for cookie, an array for set-cookie, and first-value-wins for single-value headers.

6.8.0 was published on 2026-10-10. Because .npmrc sets package-lock=false and min-release-age=7, CI started installing it around 2026-10-17. That is after the last green run on main (2026-10-05). fastify 5 depends on light-my-request@^6.0.0, so every install now gets the new behaviour.

Fix

Update the test expectation to 'just-the-first, and-the-second'. The handler now sees what a real Node HTTP server would expose for a header sent twice, so the library code needs no change. Nothing else in the suite depends on the old joining.

Verification

  • Reproduced locally on Node v24.18.0 with a fresh npm install --ignore-scripts (fastify 5.12.8, light-my-request 6.8.1): node --test --test-name-pattern='POST with base64 encoding' test/basic.test.js failed with 500 == 200. Logging the request inside the handler showed x-multi: 'just-the-first, and-the-second'.
  • Ran the unchanged test with light-my-request 6.6.0 swapped in: it passed. This confirms the light-my-request change is the cause.
  • After the fix:
    • npm run lint: clean
    • npm test: unit tests 39/39 passed; tstyche 18/18 assertions passed

This unblocks CI for the open PRs #322 and #323, which only touch workflows and fail on this test.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Sfj4nEK6BT2fQMtaQ22BnF

The "POST with base64 encoding" test started failing with a 500 because
an assertion inside the route handler threw. The base64 body handling
is fine: the failing assertion was on the `x-multi` header built from
the event's `multiValueHeaders`.

This library passes multi-value headers to `app.inject()` as an
array. light-my-request used to coerce such arrays with `'' + value`,
producing `'just-the-first,and-the-second'`. Since light-my-request
6.8.0 (fastify/light-my-request#388, published 2026-10-10 and picked up
by CI once it passed the 7 day min-release-age) array header values are
aggregated the same way Node's HTTP server combines repeated header
lines, joined with ', ', so the handler now receives
'just-the-first, and-the-second'.

That is the correct behaviour for a header sent multiple times, so
update the test expectation instead of changing the library.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sfj4nEK6BT2fQMtaQ22BnF

This branch has not been deployed

No deployments
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.

2 participants