fix(http): answer in MessagePack to MessagePack bodies sent without Accept header #93

Closed
opened 2026-12-03 09:51:48 +00:00 by crapougnax · 0 comments
Owner

Problem

msgPackContentNegotiation() (@quatrain/http) only encodes the response as MessagePack when the client sends Accept: application/x-msgpack (or ?format=msgpack). A client that posts a MessagePack body but omits Accept gets a JSON response, which a MessagePack-only client cannot decode:

Unexpected msgpack code 123 (positive fixint) encountered.   // 123 = '{'

Seen in TotalYmage staging with the Unity client on POST /environments/:uid/versions/:vid/audit (the Unity HTTP helper does not set Accept on every request).

Expected behaviour

  • Respond in MessagePack when the request body is MessagePack, unless Accept explicitly asks for JSON (application/json or +json).
  • Unchanged: explicit Accept: application/x-msgpack / ?format=msgpack still wins; JSON bodies or body-less requests without Accept still get JSON.

Scope

  • packages/http/src/MsgPack.ts: new exported shouldRespondMsgPack(req, isMsgPackBody) used by the middleware.
  • Unit tests for the negotiation matrix.
## Problem `msgPackContentNegotiation()` (`@quatrain/http`) only encodes the response as MessagePack when the client sends `Accept: application/x-msgpack` (or `?format=msgpack`). A client that posts a **MessagePack body** but omits `Accept` gets a **JSON** response, which a MessagePack-only client cannot decode: ``` Unexpected msgpack code 123 (positive fixint) encountered. // 123 = '{' ``` Seen in TotalYmage staging with the Unity client on `POST /environments/:uid/versions/:vid/audit` (the Unity HTTP helper does not set `Accept` on every request). ## Expected behaviour - Respond in MessagePack when the request body is MessagePack, unless `Accept` explicitly asks for JSON (`application/json` or `+json`). - Unchanged: explicit `Accept: application/x-msgpack` / `?format=msgpack` still wins; JSON bodies or body-less requests without `Accept` still get JSON. ## Scope - `packages/http/src/MsgPack.ts`: new exported `shouldRespondMsgPack(req, isMsgPackBody)` used by the middleware. - Unit tests for the negotiation matrix.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
quatrain/core#93
No description provided.