Fix validation response parsing and diagnostics - #42
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The redaction logic currently leaks string lengths and changes scalar value types (numbers/bools become strings), which undermines the stated “type-preserving” diagnostic guarantees and can disclose sensitive metadata.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR hardens the Xiaomi validation-response parsing in the Rust core and adds a CLI diagnostic artifact (flash --dump-json <PATH>) intended to help troubleshoot token-extraction failures (Issue #8) without leaking sensitive values.
Changes:
- Replaces strongly-typed, case-sensitive validation response parsing with case-insensitive recursive
serde_json::Valueextraction forPkgRom,Validate,Token,Erase, andCode.message. - Adds
flash --dump-json <PATH>to write a redacted validation-response JSON shape for issue reports. - Updates recovery safety documentation and fixes formatting/lint issues in the portable GUI.
File summaries
| File | Description |
|---|---|
| src/validate.rs | Introduces schema-flexible validation parsing and implements redacted JSON diagnostic serialization. |
| src/main.rs | Adds --dump-json to flash and writes the redacted diagnostic after validation. |
| docs/wiki/Recovery-safety.md | Documents the validation diagnostic flow and intended safety properties of the dump. |
| crates/gui/src/main.rs | Repairs formatting/lint issues and simplifies a download result return path. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Owner
Author
|
@copilot review |
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.
What changed
PkgRom,Validate,Token,Erase, andCode.messagewithout casing assumptions and through response wrappers.flash --dump-json <PATH>with fully redacted scalar values so issue reports preserve response shape without exposing tokens, serials, messages, or ROM URLs.dev.This prepares a safe diagnostic artifact for #8. It does not claim a real yunluo recovery flash until the reporter verifies the artifact.
Validation
cargo fmt --all -- --checkcargo test --workspace --locked(32 passed)cargo clippy --workspace --all-targets --locked -- -D warningscargo check --manifest-path fuzz/Cargo.toml --lockedpwsh -NoProfile -File tools/check-locales.ps1pwsh -NoProfile -File tools/preflight.ps1including Windows x64 release build, WinUI publish, startup smoke test, and Inno installerSafety checklist