Repository navigation
fix(plugins): never silently rewrite an unparsable source registry (niubash#178) - #246
Merged
Merged
Conversation
…iubash#178) A registry.toml that fails to parse used to read as an empty view with only a RUST_LOG warning, and the next successful sync rewrote the file without the corrupt line — silently dropping the persisted pin commit, checksum and trust state riding in it. Now the corrupt bytes are treated as user data: - reads snapshot the file byte-for-byte to registry.toml.corrupt and warn once per distinct content (visible on stderr, not just RUST_LOG); - registry writes are REFUSED while the on-disk file fails to parse — sync and install fail loudly as 'failed' rows instead of rewriting; the pin/trust records survive until a human repairs the file; - install refuses before any fetch/promotion (no half-installed tree); - 'niu doctor' surfaces the corruption explicitly, naming the parse error's line and the preserved sidecar, instead of 'none installed'. Consent is the human repair: once the file parses again, writes and normal sync resume and the records round-trip. Closes niubash#178
caomengxuan666
added a commit
that referenced
this pull request
Oct 10, 2026
…notes draft (#254) - Version 1.3.4 -> 1.4.0 (workspace root + crates/niubash-runtime; Cargo.lock synced; internal niubash-runtime dep requirement aligned 1.2.5 -> 1.4.0). The rubash engine requirement stays 1.3.4: it is semver-open (^1.3.4 admits the engine's 1.4.0), and the committed [patch] resolves it to the local ../rubash worktree, whose Cargo.toml still says 1.3.4 until the engine cuts its own release. - CHANGELOG: the Unreleased section becomes [1.4.0] - 2026-10-10. Also repairs the committed merge damage from #243 (stray conflict marker and the #241 doctor-advice entry glued onto the carapace entry) and folds in the merged cycle: #235 #239 #246 #247 #250 #251 #252 #253 plus a compact rubash 1.4.0 engine summary. #240's P2-batch content stays under [1.3.4] where the file already records it (no dup). - docs/release-notes-1.4.0-draft.md: zh+en draft release notes (Added / Fixed / Performance), winuxcmd #1151/#1154-#1157 marked as in-flight for the coordinator, plus the local verification log: release build PASS (niu.exe 10.6 MB), MSIX packed unsigned with a placeholder identity (5.1 MB), wpm-source main carries all four preinstall packages, and cargo publish --dry-run chain findings (rubash -> niubash-runtime -> niubash, blocked on the engine's crates.io release). No tag, no release workflow trigger, no in-flight PRs merged.
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.
Closes #178
Problem
A
registry.tomlline that fails to parse made every read see an empty view (only a RUST_LOG warning), and the next successfulniu plugin syncrewrote the file without it — silently dropping the persisted pin commit/checksum/trust state.Fix — corrupt bytes are user data
registry.toml.corruptnext to the file, and a visible warning (stderr, not just RUST_LOG) is emitted exactly once per distinct content.write_source_registryrefuses while the on-disk file fails to parse — sync surfaces afailedrow naming the parse error instead of rewriting; the corrupt file (pins included) survives untouched.install_or_adoptrefuses before any fetch/promotion, so no half-installed tree or misleading retry.niu doctorshows an explicit UNPARSABLE row (parse error's line + sidecar path) instead of the misleading "none installed".Consent = the human repairs (fixes or removes) the file; writes and normal sync then resume and the records round-trip.
Regression tests
corrupt_registry_is_preserved_and_never_silently_rewritten(sources): failed line + pin survive byte-for-byte; warn-once; write refused; post-repair write/read round-trips trust + commit pin.sync_never_rewrites_a_corrupt_registry(sync): end-to-end sync refuses with afailedrow, registry + sidecar survive, post-repair sync adopts the pinned record and activates.Full
niubash-runtimelib suite: 394 passed; the only 3 failures (plugins::distros::tests::apply_*) reproduce identically on clean HEAD (bundled niugit cannot clone the MSYS-style local mirror path in this environment) and are unrelated.