HarperFast / HarperFast/harper

Accept: application/x-msgpack on a collection GET returns a JSON-wrapped Buffer, not raw msgpack

Open Beginner friendly
#1,483 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
89
Forks
10
Avg merge
2d 6h
Merged PRs (30d)
200

Description

`Accept: application/x-msgpack` on a **collection** GET (`GET /T/`) returns a JSON-serialized Buffer — `{"contentType":"application/msgpack","data":{"type":"Buffer","data":[...]}}` — instead of raw msgpack bytes. The `Content-Type` header says `application/x-msgpack` but the body is JSON, so a msgpack client cannot decode it.

**Root:** `resources/contentTypes.ts:221-226` — the msgpack serializer returns `pack(data)` (a Node Buffer) for non-streaming (collection) data; Fastify's default JSON serializer then JSON-stringifies that Buffer. The **CBOR** path avoids this by returning a `Readable` stream (`EncoderStream`), which Fastify pipes raw. A single-record point-GET msgpack response is also fine (different code path).

**Fix:** have the msgpack collection serializer return a stream — `Readable.from([pack(data)])` — like the CBOR path.

**Scope/clean legs:** CBOR (single + collection) works; single-record cross-format round-trips work; q-value Accept negotiation works; GraphQL is JSON-only by design.

**Severity:** medium — msgpack list endpoints are unusable; CBOR is the working binary format. Related: `application/msgpack` (without the `x-`) isn't a registered media type (use `application/x-msgpack`).

**Repro:** `npm run test:integration -- "integrationTests/qa-scratch/qa358-content-negotiation.test.ts"`

— filed by KrAIs (Claude) on Kris's behalf (qa-explorer campaign, main @ 28db4fde4 v5.1.12)

Contributor guide

Open the contributing guide

Research direction

Start in resources/contentTypes.ts:221-226, where the non-streaming msgpack collection serializer returns pack(data), and compare it with the CBOR stream path. Run npm run test:integration -- "integrationTests/qa-scratch/qa358-content-negotiation.test.ts" first. Done means collection GET responses accepted as application/x-msgpack contain raw msgpack bytes that the test can decode.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.