Skip to content

Fix validation response parsing and diagnostics - #42

Merged
Has-X merged 2 commits into
devfrom
fix/issue-8-validation-response
Aug 24, 2026
Merged

Fix validation response parsing and diagnostics#42
Has-X merged 2 commits into
devfrom
fix/issue-8-validation-response

Conversation

@Has-X

@Has-X Has-X commented Aug 24, 2026

Copy link
Copy Markdown
Owner

What changed

  • Parse PkgRom, Validate, Token, Erase, and Code.message without casing assumptions and through response wrappers.
  • Accept the standard token string, nested token object, allowed-ROM array, and string or boolean erase variants.
  • Add flash --dump-json <PATH> with fully redacted scalar values so issue reports preserve response shape without exposing tokens, serials, messages, or ROM URLs.
  • Document the diagnostic flow and repair the portable GUI lint already present on 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 -- --check
  • cargo test --workspace --locked (32 passed)
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo check --manifest-path fuzz/Cargo.toml --locked
  • pwsh -NoProfile -File tools/check-locales.ps1
  • pwsh -NoProfile -File tools/preflight.ps1 including Windows x64 release build, WinUI publish, startup smoke test, and Inno installer

Safety checklist

Copilot AI lite review requested due to automatic review settings August 24, 2026 10:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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::Value extraction for PkgRom, Validate, Token, Erase, and Code.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.

Comment thread src/validate.rs Outdated
@Has-X

Has-X commented Aug 24, 2026

Copy link
Copy Markdown
Owner Author

@copilot review

Copilot stopped work on behalf of Has-X due to an error August 24, 2026 10:58
@Has-X
Has-X merged commit 10ea6a7 into dev Aug 24, 2026
1 check failed
@Has-X
Has-X deleted the fix/issue-8-validation-response branch August 24, 2026 10:58
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.

2 participants