Fix session creation failing for every real browser - #3
Merged
Conversation
The receiver's `createSession` sent `content-type: application/json` with no body. Fastify's default parser rejects that combination with FST_ERR_CTP_EMPTY_JSON_BODY and a 400 before the route runs, so the receiver could never create a session: the page showed "connection lost" and every retry failed instantly. The bug predates the single-entry-point merge — it is unchanged since the first commit — but nothing caught it, because a POST *without* the header takes a different path in Fastify and succeeds. Both the CI smoke test and the manual one used curl and plain fetch without a content-type, so every check passed against an endpoint no browser could actually use. Two changes: - The receiver drops the header. The request carries no body, so declaring a JSON one was simply wrong. - The relay tolerates an empty body on `application/json` instead of 400ing. No endpoint here takes a request body, so a client that sets the header out of habit should not get a hard failure it cannot diagnose — the Phase 1 Android app is the obvious next caller to trip on it. Malformed JSON is still a 400. Adds the regression test that was missing: a POST shaped exactly like the browser's, plus one asserting malformed JSON is still rejected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The receiver's
createSessionsentcontent-type: application/jsonwith no body. Fastify's default parser rejects that withFST_ERR_CTP_EMPTY_JSON_BODYand a 400 before the route runs, so the receiver could never create a session — the page showed "connection lost" and every retry failed instantly.The bug predates the single-entry-point merge —
createSessionis unchanged since the first commit. It went unnoticed because a POST without the header takes a different path in Fastify and succeeds, and both the CI smoke test and the manual one used exactly that shape. Every check passed against an endpoint no browser could use.Changes
application/jsonrather than 400ing. No endpoint takes a request body, so a client setting the header out of habit shouldn't get an undiagnosable failure — the Phase 1 Android app is the obvious next caller to trip on it. Malformed JSON is still a 400.64 tests pass (was 62). Verified in a built container: browser-shaped POST → 200, no-content-type POST → 200, malformed JSON → 400, full pair-and-scan → ALL PASS.
🤖 Generated with Claude Code