Skip to content

fix(cli): rvt-dump takes the resource-limit options and goes on past a stream it cannot read, rvt-info refuses a preview that is not a whole PNG, and gen-fixture refuses a name with a path in it (#1885) - #1906

Merged
DrunkOnJava merged 2 commits into
mainfrom
fix/1885-dump-preview-fixture
Nov 13, 2026

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Items 12, 13 and 14 of #1885, the three that are neither the write path (#1893) nor the CLIs' shared output rules (#1891, landed): rvt-dump takes the resource-limit options and goes on past a stream it cannot read, rvt-info --extract-preview refuses a preview that is not a whole PNG, and gen-fixture refuses a name with a path in it. Part of #1885; the issue closes when #1893 has landed too.

Motivation

Batch 5's audit of the CLIs that write files (main at e57db423; each finding confirmed by a second reader):

  • 12. rvt-dump opened every file under the default limits, so one stream over 256 MiB stopped the whole dump with an error and no option changed it (rvt_dump.rs:59,72); and it kept every inflated partition in the reader's memo though it writes them one at a time (reader.rs:965-968; the memo's budget is 16 GiB).
  • 13. --extract-preview wrote what the stream held from the PNG signature on and said "preview PNG written", when a preview cut short has no IEND chunk (rvt_info.rs:156-159).
  • 14. gen-fixture NAME with no --output wrote tests/fixtures/synthetic-NAME.rvt, so --name ../x wrote outside the folder (gen_fixture.rs:161-164). A developer tool and the user's own argument; low.

Changes

  • src/bin/rvt_dump.rs: --max-stream-bytes, --max-inflate-bytes, --large-model and --allow-partial as rvt-gltf has them (rvt::cli::open_limits, unread_stream_report); a stream over the limit prints "not read: over the stream limit" and the dump goes on; at the end the reader's list of what a limit left unread goes to stderr and the exit status is 3 unless --allow-partial. A partition is written from the reader's shared buffer, not a copy, and RevitFile::release_inflated_partitions (was pub(crate), now pub) runs after each stream.
  • src/bin/rvt_info.rs: ends_with_iend; a preview without an IEND chunk is not written, and the command exits 1 saying the preview is cut short.
  • src/bin/gen_fixture.rs: a name with / or \ is refused when it would become a file name under tests/fixtures.
  • tests/cli_ergonomics.rs (three tests, appended), src/reader.rs (the method's visibility and doc), changelog.d/fixed/1885-dump-preview-fixture.md.

Testing

Unit tests are banned in this repository; each check is end to end through the built binaries, on a file gen-fixture makes:

  • rvt_dump_lists_a_stream_over_the_limit_and_dumps_the_rest: with default limits the dump exits 0 with nothing on stderr; under --max-stream-bytes 100 it exits 3, lists BasicFileInfo as not read, writes no file for it, dumps the preview stream after it, and reports the unread streams and --allow-partial on stderr; with --allow-partial it exits 0.
  • extract_preview_writes_a_whole_png_and_refuses_one_cut_short: the fixture's preview comes out as a PNG ending in IEND; the same file with its preview stream replaced by a PNG signature and half an IHDR chunk exits 1, says "cut short" and writes nothing.
  • gen_fixture_name_with_a_path_in_it_writes_nothing: ../escape, a/b and a\b exit 1 with "path separator" and make no folder; plain writes tests/fixtures/synthetic-plain.rvt under CARGO_MANIFEST_DIR.
  • This PR's CI (head d83987c, run 43418515306, every job green): the three tests above pass on Linux, Windows and macOS. No export moves.

Not measured: the memory rvt-dump saves by dropping each partition after it is written (no peak was recorded before or after; the saving is by construction, one inflated partition at a time instead of all of them).

Audit-honesty checklist

  • README / docs reflect the current state after this PR (rvt-dump --help and rvt-info --help are the docs of these options)
  • A user-visible change has its entry as a fragment under changelog.d/fixed/
  • N/A: no limitation resolved or introduced
  • Commit messages describe WHAT changed and WHY
  • No emojis in code, docs, or commit messages
  • No private paths, personal email addresses, or internal jargon in committed files
  • N/A: no reverse-engineering finding

Legal and contribution hygiene

  • I agree this work is licensable under Apache-2.0
  • This PR contains no Autodesk proprietary source, decompiled internals, or NDA'd SDK content
  • No new test fixtures

Breaking changes

rvt-dump exits 3 where a resource limit left a stream unread (it used to stop with exit 1 on a stream over the stream limit, and exit 0 on a partition cut short by an inflate limit); --allow-partial restores 0. rvt-info --extract-preview exits 1 for a preview cut short, where it wrote the bytes. RevitFile::release_inflated_partitions is a new public method.

Related issues

Part of #1885 (items 12 to 14).

…a stream it cannot read, rvt-info refuses a preview that is not a whole PNG, and gen-fixture refuses a name with a path in it (#1885)
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 13, 2026 11:37
@DrunkOnJava

Copy link
Copy Markdown
Owner Author

Approved at b468e6d by the review bot as a self-approval, under Griffin's answer of 2026-11-12 ("You are allowed to self-approve"): rvtDevelop's session has not read the head sent to it at about 11:50 UTC. I re-read the whole diff (rvt-dump's limits, the report and exit 3, the per-stream release and the Bytes enum, the IEND check, the separator check, the three end-to-end tests) as if another session had written it. The push since the tests ran is the merge of main after #1893 landed; the PR's own diff against main is the six files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant