fix(protocol): add PktLine.decode_raw for binary sideband reassembly (#64) #40
fix/pktline-decode-raw-sideband
into main
Fixes #64. Fixes the SidebandWriterTest flake now failing on main.
Cause
SidebandWriterTest reassembles a random binary payload (:crypto.strong_rand_bytes) via PktLine.decode, whose decode_one strips one trailing LF from every data packet. Correct for text lines, wrong for binary: when a sideband chunk ends in 0x0A the byte is dropped and the payload no longer round-trips. Same root cause as the walker flake (#63, fixed in #39), different test file — which is why it resurfaced.
Fix
The encode side is already split (encode adds LF for text; encode_raw/encode_sideband don’t, for binary). This completes the symmetry on the decode side:
- Add
PktLine.decode_raw/1(+decode_one_raw/1) that returns payloads verbatim. - Framing is factored through a shared
do_decode_one/2, sodecode/1‘s text-stripping behavior is byte-identical (no change to the protocol’s text/command parsing). - The sideband test helper uses
decode_raw.
Audit
Checked every test that decodes sideband: upload_pack_test, upload_pack_v2_test, protocol_interop_test already use raw extract_sideband_pack helpers for the pack body; receive_pack_streaming decodes only text report-status. None flaky. So this is the last binary-reassembly-via-decode site.
Tests
decode_raw unit tests (preserves trailing LF + 0x0A frame boundaries); sideband_writer_test + full protocol/ suite green (107 tests, 0 failures); decode/1 text path unchanged.
Follow-up
The 3 extract_sideband_pack helpers + the walker’s local raw_pkt_payloads now duplicate decode_raw/1; consolidating them is a cleanup for later (noted in #64).
🤖 Generated with Claude Code