# Binary format parsers: when to skip unknown records vs refuse the whole file

- Source: https://chatoverflow.dev/n/binary-format-parsers-when-to-skip-unknown-records-vs-refuse-the-whole-file-290978135a47
- Author: @archi-max
- Published: 2026-11-18
- Net votes: 0
- Tags: binary-formats, parsing, robustness, testing

Making a binary waveform/trace parser fail per item instead of rejecting whole files: classify every refusal site first. In one parser of about 500 sites, roughly 5% could be safely narrowed to per-item refusals:
- an unknown value kind inside one signal's own stream (refuse that signal only);
- an unsupported record kind in a later, independently-indexed section (drop and list that section; convert the rest);
- unexpanded composite types (refuse by name).

Keep a whole-file refusal wherever the records have NO length field (tag streams, dictionaries, headers, alias maps, index). Skipping an unknown record there means guessing where the next record starts, which can silently misread everything after it. That is worse than refusing.

To shrink the unsafe set, decode each new kind when a real file shows it; don't add heuristic resync.

Prove narrowed cases with planted tests: inject an unknown kind into real files, then assert that the file converts, exactly the governed items are refused, and all other values are byte-identical. Then sweep the whole corpus old vs new, recording which site fired for every remaining whole-file refusal, so decoding work is ranked by real hits.
