You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
id(libsql): decode chunked HTTP bodies as bytes before UTF-8 conversion #8504
effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)status:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
pkgs/id/src/foreign_libsql.rs:833-849 converts the entire raw HTTP response using String::from_utf8_lossy before removing chunk framing. dechunk then interprets the HTTP chunk size (a byte count) as a Rust string slice boundary at lines 856-873. The production transport calls this parser at line 765.
A valid chunked response can split the UTF-8 bytes of é across two one-byte chunks: 1\r\n\xc3\r\n1\r\n\xa9\r\n0\r\n\r\n. The lossy conversion replaces each incomplete byte sequence with a multi-byte replacement character; slicing it at byte 1 panics. Even where it does not panic, converting before reassembly can corrupt valid UTF-8. A remote response can therefore interrupt the operation rather than returning its data or a transport error.
Acceptance criteria
Parse and validate chunk framing using byte slices, concatenate chunk payload bytes, and only then decode the assembled body according to the transport contract.
Valid UTF-8 split across chunk boundaries round-trips without corruption or panic; cover this with a regression test.
Malformed or truncated framing returns a transport error rather than panicking, with focused tests.
Preserve correct handling of ordinary chunked and non-chunked responses.
🤖 Agent note · triaged + picked up (inline triage)
Agent: repo-worker-code (queue task 14865, lane code-n)
Session: Muse scheduled lane N, 2026-11-11T03:54Z
Triage: work kind task/small-fix; priority priority/normal (a remote chunked response can panic the transport or corrupt valid UTF-8); effort effort/s (one function pair + regression tests in pkgs/id/src/foreign_libsql.rs); kind kind/bug.
Verified:parse_http_response lossy-converts the whole raw response to a string before dechunking, and dechunk slices that string at the chunk size (a byte count) — a multi-byte UTF-8 sequence split across chunks panics or corrupts, exactly as filed (pkgs/id/src/foreign_libsql.rs:833-873 on main).
First concrete step: rewrite framing on byte slices — split head/body as bytes, dechunk into assembled bytes, decode UTF-8 only after assembly — with regression tests for the split-é chunk pair, malformed/truncated framing (error, never panic), and ordinary chunked + non-chunked responses.
Acceptance check: the tests above pass in cargo test -p id foreign_libsql and no panic path remains in the chunk parser.
Fix: byte-first chunk parsing in pkgs/id/src/foreign_libsql.rs — head/body split on raw bytes, dechunk(&[u8]) -> Vec<u8> concatenates payload bytes untouched, UTF-8 is decoded (lossy, the prior body contract) only after assembly. Malformed/truncated framing returns the existing transport errors; no string slicing at byte counts remains.
Verification: the new split-UTF8 regression test panicked on the unpatched code at foreign_libsql.rs:871 (end byte index 1 is not a char boundary); post-fix cargo test -p id --lib foreign_libsql — 21 passed / 0 failed; changed hunks rustfmt-clean. Codex review was still running when the PR merged under standing merge authority (no findings posted at merge time); any late Codex finding on PR fix(id): decode chunked HTTP bodies as bytes before UTF-8 conversion (#8504) #8515 should be fixed forward on main.
effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)status:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
Activity
developing-today commentedon Nov 11, 2026
CODE-2539
dezren39 commentedon Nov 11, 2026
🤖 Agent note · triaged + picked up (inline triage)
task/small-fix; prioritypriority/normal(a remote chunked response can panic the transport or corrupt valid UTF-8); efforteffort/s(one function pair + regression tests inpkgs/id/src/foreign_libsql.rs); kindkind/bug.parse_http_responselossy-converts the whole raw response to a string before dechunking, anddechunkslices that string at the chunk size (a byte count) — a multi-byte UTF-8 sequence split across chunks panics or corrupts, exactly as filed (pkgs/id/src/foreign_libsql.rs:833-873 on main).échunk pair, malformed/truncated framing (error, never panic), and ordinary chunked + non-chunked responses.cargo test -p id foreign_libsqland no panic path remains in the chunk parser.Merge pull request #8515 from developing-today/queue/14865-8504-dechu…
dezren39 commentedon Nov 11, 2026
🤖 Agent note · done (triaged inline, fixed + merged)
pkgs/id/src/foreign_libsql.rs— head/body split on raw bytes,dechunk(&[u8]) -> Vec<u8>concatenates payload bytes untouched, UTF-8 is decoded (lossy, the prior body contract) only after assembly. Malformed/truncated framing returns the existing transport errors; no string slicing at byte counts remains.end byte index 1 is not a char boundary); post-fixcargo test -p id --lib foreign_libsql— 21 passed / 0 failed; changed hunks rustfmt-clean. Codex review was still running when the PR merged under standing merge authority (no findings posted at merge time); any late Codex finding on PR fix(id): decode chunked HTTP bodies as bytes before UTF-8 conversion (#8504) #8515 should be fixed forward on main.