Repository navigation
fix(writer): rvt-write --dry-run checks what the write would refuse, a patch is refused that frames a stream otherwise than it is stored, and an empty or self-copying write is a plain copy (#1885) - #1893
Merged
Conversation
…vt-info writes a file's text as text in a CSV cell, rvt-dump escapes a stream's name, and rvt-ifc writes its IFC whole under --observation (#1885) Items 8, 9, 10 and 11 of #1885, and the same-file half of its item 6's neighbours, each fixed once where the CLIs share it: - rvt::cli::same_file asks whether two paths are one file (resolved paths, or a hard link on Unix). rvt-gltf, rvt-sheet and rvt-schedule compared the output path with the input path as typed, so ./model.rvt and a link got through; rvt-ifc compared nothing, and rvt-ifc model.rvt -o model.rvt replaced the Revit file with the IFC. All four now check before they export. - rvt::cli::csv_text is the one rule for a text cell: RFC 4180 quoting, and a leading ' where the text starts with = + - @ tab or CR. rvt-info -f csv put a title, a user name or a path of a crafted file into a cell as it stood, so a spreadsheet ran it as a formula. rvt-schedule's cells already had the rule, written out there; they take it from here too, with no change to their output. - rvt-dump printed a stream's name as it stood, control characters included; it prints it escaped. The file name it writes to was already sanitised. - rvt-ifc --observation wrote the IFC straight to the output's name, so a killed export left a truncated .ifc there. It is written beside the output and renamed when whole, as the export without --observation is. End to end: the tier-1 fixture is given to rvt-gltf, rvt-sheet, rvt-schedule and rvt-ifc with the output named ./model.rvt, through a symbolic link and through a hard link, and every one refuses and leaves the file as it was; rvt-info -f csv on a file named =1+1.rvt writes '=1+1.rvt in the path cell. csv_text is a pure helper and has failure-first tests next to it. Part of #1885 (its rvt-write items follow in their own change).
…a patch is refused that frames a stream otherwise than it is stored, and an empty or self-copying write is a plain copy (#1885) Items 1 to 7 of #1885: - validate_patches (new) is what write_with_patches refuses before it writes: a stream the file lacks (StreamNotFound), a framing the stream is not stored in and a patch that would span a checksummed page (WriteRefused). write_with_patches calls it, and so does rvt-write --dry-run, which needed --patches although its help says otherwise and exited 0 without looking at any stream. - The manifest alone chose a stream's framing on disk, and verification read the stream back with the same framing, so a stream written in the wrong framing passed. A patch framed RawGzipFromZero or CustomPrefix8 is refused unless the stream is stored that way, read from its first bytes; Verbatim is the caller's own framing and is never checked. - A base64 value that decodes to no bytes ("=", "") emptied the stream; it is refused, and the manifest says "new_decompressed": [] to mean it. - An empty patches array wrote the copy and then exited 1 with "0 stream(s) failed verification"; it is a plain copy, as the writer already made it. - One file under two names (a link, ./x) is one file: a write with no patch leaves it as it is, where it rebuilt the container in place, and the copy path removes its temporary file when the copy or the rename fails. End to end, on the tier-1 fixture: a dry run with no manifest exits 0; a missing stream and a wrong framing are refused by the dry run and by the write, and leave no file; "=" and "" are refused; an empty manifest copies the file byte for byte; the file onto itself, spelled two ways, is left as it was with no temporary beside it. The real-file round trip of Formats/Latest and Global/Latest on the twelve family releases (cli_real_files) is unchanged. Part of #1885 (items 12 to 14 follow).
The conflict was in tests/cli_ergonomics.rs, where both branches added tests at the same place; both sets are kept. The result differs from main by this branch's own four files. The changelog fragment now says the library's write_with_patches refuses a mismatched framing.
Owner
Author
|
Approved at 49d928a 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:40 UTC, and its earlier approval of this PR was dismissed by the push that merged main. I re-read the whole diff (writer.rs, rvt_write.rs, the tests) as if another session had written it; the push since that approval is the merge of main only. |
DrunkOnJava
added a commit
that referenced
this pull request
Nov 13, 2026
DrunkOnJava
added a commit
that referenced
this pull request
Nov 13, 2026
…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) ## 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: - [x] `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. - [x] `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. - [x] `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`. - [x] 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 - [x] README / docs reflect the current state after this PR (`rvt-dump --help` and `rvt-info --help` are the docs of these options) - [x] A user-visible change has its entry as a fragment under `changelog.d/fixed/` - N/A: no limitation resolved or introduced - [x] Commit messages describe WHAT changed and WHY - [x] No emojis in code, docs, or commit messages - [x] No private paths, personal email addresses, or internal jargon in committed files - N/A: no reverse-engineering finding ## Legal and contribution hygiene - [x] I agree this work is licensable under Apache-2.0 - [x] This PR contains no Autodesk proprietary source, decompiled internals, or NDA'd SDK content - [x] 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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Items 1 to 7 of #1885, the
rvt-writeandwriter.rshalf.rvt-write --dry-runchecks what the write would refuse, a patch that frames a stream otherwise than it is stored is refused, a base64 value that empties a stream is refused, and an empty manifest or a file copied onto itself is a plain copy. Part of #1885.Stacked on #1891, whose
rvt::cli::same_filethis uses: its branch is merged into this one (863eb146), so the diff shows its commits until #1891 lands; merge #1891 first and this PR's own change is what remains.Motivation
Batch 5's audit of the write path (main at
e57db423; each finding confirmed by a second reader, items 1, 2 and 8 also re-read by the maintainer session):--patchesis required even with--dry-run(it is unwrapped beforedry_runis looked at), so the manifest-less dry run the flag's help documents is unreachable; and the dry run exits 0 without checking that the streams exist or applying the writer's own refusals (writer.rs:206-217).writer.rs:197,:705) and verification reads back with the same framing, so aFormats/Latestwritten with the wrong framing passes."=") decodes to zero bytes and silently empties the stream.patchesarray writes the copy and then exits 1 with0 stream(s) failed verification:all_matchedis false for zero streams.--src X --dst Xskips both fast paths and rebuilds the container in place, contradicting the byte-for-byte promise for a patch-free copy. (The second reader refuted that the source is destroyed:RevitFile::openreads the whole file first.).<dst>.copy-<pid>behind when the copy or the rename fails, against the module doc.Changes
src/writer.rs:validate_patches(new, public) is whatwrite_with_patchesrefuses before it writes: a missing stream, a framing the stream is not stored in (read from the stream's first bytes: gzip from byte 0, or eight bytes and then gzip;Verbatimis never checked), and a stored page.write_with_patchescalls it. The path choice usesrvt::cli::same_file(fix(cli): the CLIs refuse to write over their input under any name, rvt-info writes a file's text as text in a CSV cell, rvt-dump escapes a stream's name, and rvt-ifc writes its IFC whole under --observation (#1885) #1891) in place of comparing the paths as typed: a patch-free write of a file onto itself returns without touching it, and the copy path removes its temporary file when the copy or the rename fails.src/bin/rvt_write.rs: a dry run needs no manifest and callsvalidate_patches; a base64 value that decodes to nothing is refused with the way to say it on purpose ("new_decompressed": []); zero patches is a plain copy, not a verification failure; the source opened for the dry run is dropped before the write opens it.tests/cli_ergonomics.rs: the end-to-end checks below. Fragment:changelog.d/fixed/1885-rvt-write-checks.md.Not in this PR: items 12 to 14 of #1885 (
rvt-dumpmemory and limits, the preview's PNG check,gen-fixture --name), which are not the write path.Testing
Unit tests are banned in this repository; every check below is end to end on the tier-1 fixture, through the built
rvt-write:rvt_write_dry_run_needs_no_manifest_and_checks_what_the_write_would: a dry run with no manifest exits 0; a manifest naming a stream the file lacks, and one framingBasicFileInfo(stored as it stands, not as gzip) asRawGzipFromZero, exit 1 with the stream ornot gzip-framedin the message, with--dry-runand without, and leave no file.rvt_write_refuses_a_base64_value_that_empties_a_stream:"="and""exit 1 withdecodes to no bytesand leave no file.rvt_write_with_no_patch_copies_the_file_byte_for_byte_...: an empty manifest copies the file byte for byte and exits 0; the copy written onto itself, spelled two ways, is left as it was, with no dot-file temporary beside it.cli_real_files::write_round_trips_or_refuses_a_streams_own_bytes(Corpus health, the 12 family releases):Formats/LatestframedRawGzipFromZeroandGlobal/LatestframedCustomPrefix8are still written and read back, which is the check that the framing rule refuses nothing real. I cannot build locally (rule of this repository), so CI is the first compile of this change.Audit-honesty checklist
rvt-write --helpis the doc of the dry run)changelog.d/fixed/Legal and contribution hygiene
Breaking changes
rvt::writer::write_with_patches(andrvt-write) now returnWriteRefusedfor a patch framedRawGzipFromZeroorCustomPrefix8over a stream stored otherwise. A caller that frames the bytes itself passesVerbatim, which is unchanged. The public itemvalidate_patchesis added.Related issues
Refs #1885 (items 1 to 7; the issue stays open for items 12 to 14).