Repository navigation
Description
Bug: bin proxies corrupt multibyte UTF-8 split across request-body chunks
Eight proxies in bin/ accumulate the request body with bodyText += chunk, where chunk is a Buffer and no handler calls req.setEncoding. Each chunk is therefore stringified on its own: a multibyte UTF-8 sequence straddling a chunk boundary decodes to U+FFFD replacement characters on both sides, and the corrupted text is parsed and forwarded upstream as if the client had sent it. JSON still parses (the damage lands inside string values), so prompts containing emoji/CJK/accented text are silently garbled — no error anywhere.
Evidence (verified this run, main fe62dc7)
Handlers with the pattern (no setEncoding in any of these files):
bin/clef-proxy.mjs:194-196bin/agy-proxy.mjs:844-846bin/antigravity-ls-proxy.mjs:751-753bin/claude-code-proxy.mjs:721-723bin/codex-proxy.mjs:1069-1071bin/commandcode-proxy.mjs:897-899bin/design-code-proxy.mjs:180-182bin/muse-proxy.mjs:1484-1486andbin/muse-proxy.mjs:1582-1584(two handlers)
The correct house pattern already exists in the same directory: bin/antigravity-direct.mjs:700-701 collects Buffer chunks and decodes once with Buffer.concat(chunks).toString('utf8'); bin/opencode-route-proxy.mjs uses a streaming TextDecoder.
Laptop probe (~/git/fleet/probe-2026-10-31-laneB-chunksplit/, real bin/clef-proxy.mjs from the laptop clone, sha256 7eac5569… identical to sandbox main, stub upstream via CLEF_PROXY_GATEWAY_BASE): POST /v1/systemone with {"questions":{"q":"before-😀-after"}}:
- Control (single write): stub upstream receives
q = "before-😀-after"— intact. - Split (first write ends 2 bytes into the emoji's 4-byte sequence, rest 150 ms later): stub upstream receives
q = "before-���-after"— 3× U+FFFD, emoji destroyed.
Chunk boundaries are not exotic: Node's HTTP parser emits data per socket read (64 KiB high-water mark), so any non-ASCII character landing on a read boundary of a large body — or simply split by client/network segmentation, as in the probe — is corrupted.
Why it matters
These proxies front the fleet's model traffic (Muse, Codex, Muse, CommandCode, design, agy, antigravity-ls, clef). A user prompt, file content, or tool result with non-ASCII text near a chunk boundary reaches the model with replacement characters substituted in, silently — the request succeeds, the answer is just computed over garbled input. The larger and more international the payload, the more likely a hit.
Acceptance criteria
- Every handler listed above decodes the body exactly once over the complete byte stream (
Buffer.concat+ singletoString('utf8'), a streamingTextDecoderwith{stream: true}, orreq.setEncoding('utf8')), matching theantigravity-direct.mjspattern; the byte-based size caps keep working (count bytes, not decoded characters, if the accumulation changes form). - A regression test per affected proxy (or one shared test driving the pattern): a body with a multibyte character split across two writes arrives/parses byte-identical; the existing per-proxy test files (
bin/*.test.mjs) still pass. - No behavior change for ASCII bodies, oversize bodies (413 path), or malformed JSON (400 path).
Dedup
Searched open + closed issues for bodyText, chunk-boundary / U+FFFD / replacement-character / split-UTF-8 proxy terms on 2026-10-31: no existing issue covers this. Related but distinct: #1844 (proxy-relay RELAY_TARGET_PORTS parsing), #483/#494 (strict port parsing in bin/proxy-port.mjs), #690 closed (clef-proxy JSON parse error shape).
— filed by new-issue-creator-code-b (Lane B), 2026-10-31 run
Activity
12 remaining items
dezren39 commentedon Nov 1, 2026
🤖 Agent note · handed off
queue/4633-3186-body-chunk-utf8-triage(triage-only, no code diff)dezren39 commentedon Nov 2, 2026
🤖 Agent note · picked up
queue/5657-3186-split-utf8; worktree/home/user/git/fleet/5657(planned)dezren39 commentedon Nov 2, 2026
🤖 Agent note · done
3af111d928d8a5f0f6fb4a45af00ff5a3b8d95e5