Repository navigation
fix(doctor): name empty and truncated files in unreadable findings - #737
kstonekuan merged 2 commits into
Conversation
An empty file produced "not readable as MCAP: " with nothing after it, because mcap raises EndOfFile with an empty message. A file cut off mid-write reported the bytes where the footer should be, e.g. "unknown (opcode 122) record has length 7707937301489634682 that exceeds limit 4294967296". Report an empty file as empty, and a file that starts with the MCAP magic but lacks the closing magic as truncated, keeping the reader's detail. Fall back to the exception type when its message is blank. The finding code stays unreadable.
|
👋 Hi @hoangchunghien — thank you so much for your first contribution to HFlow! A maintainer will review your pull request as soon as possible. In the meantime:
💡 Tip: one open pull request per contributor at a time. Before starting an issue, check its sidebar for an assignee or a linked pull request. Either one means somebody is already on it; everything else is fair game. We are excited to have you here and appreciate your help making the project better! 🙌 |
[Low impact] The PR appears safe to merge; both previous findings are fixed.
|
Two review points from Greptile on Hebbian-Robotics#737: - A file holding only the opening magic matched itself as the end marker, so it was not named as truncated. Require room for both markers. - An OSError from the marker checks escaped diagnose and stopped the batch. Fall back to the reader's own message instead.
|
Both review points were right, fixed in 7330a91:
|
kstonekuan
left a comment
There was a problem hiding this comment.
Thanks for the fix. Ruff, formatting, ty, the full suite (2562 passed, 8 skipped), and the Markdown link check passed. LGTM.
What changes for the user
hflow doctornames the two most common reasons a recording will not open, instead of a blank or misleading message.not readable as MCAP:not readable as MCAP: the file is empty (0 bytes)not readable as MCAP: unknown (opcode 122) record has length 7707937301489634682 that exceeds limit 4294967296not readable as MCAP: the file is truncated (it starts like an MCAP file but its end marker is missing, so the recording or copy may be incomplete): unknown (opcode 122) ....mp4)not readable as MCAP: not a valid MCAP file, invalid magic: ...Why
diagnose()formats the reader's exception text into the finding.mcapraisesEndOfFilewith an empty message for an empty file. For a truncated file,get_summary()reads the footer from wherever the file now ends, so the error describes arbitrary bytes. The existingno-summaryfinding already mentions truncation, but it only fires when the summary is cleanly absent, not when reading it raises.Per the MCAP spec (
references/mcap-spec.md, "Magic"), a complete file starts and ends with\x89MCAP0\r\n. When the read fails, the doctor now checks both ends: 0 bytes means empty, opening magic without closing magic means truncated. Otherwise it keeps the reader's message, and uses the exception type when that message is blank. The finding code staysunreadable, so automation that matches codes, and the existing per-file output shape, are unaffected.docs/FORMAT.mdmentions the two cases next to the existing[error] unreadable: ...description.Validation
New regression tests in
tests/test_doctor.py:test_empty_file_is_reported_as_emptyandtest_truncated_file_is_reported_as_truncated(the latter truncates a synthesized canonical episode to half). Both failed onmainat43380acwith the messages in the table above.Ubuntu 24.04, Python 3.13, ffmpeg 9.0.2.
I wrote this with help from an AI coding assistant, then reviewed and tested it myself.
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.