Skip to content

fix(updater): validate metadata with the real consumer#2031

Merged
yyhhyyyyyy merged 4 commits into
devfrom
fix/updater-metadata-consumer-validation
Jul 26, 2026
Merged

fix(updater): validate metadata with the real consumer#2031
yyhhyyyyyy merged 4 commits into
devfrom
fix/updater-metadata-consumer-validation

Conversation

@yyhhyyyyyy

@yyhhyyyyyy yyhhyyyyyy commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow up on #2025 by validating generated updater metadata with the same parser used by installed DeepChat clients.

The release pipeline previously serialized and validated latest*.yml with the yaml package, while electron-updater consumes it through js-yaml. Valid YAML could therefore pass CI while producing different runtime value types.

Changes

  • Add an isolated adapter for electron-updater's installed parseUpdateInfo() implementation.
  • Parse the exact generated metadata bytes with both:
    • the strict release-side YAML policy parser;
    • the real updater consumer parser.
  • Require the consumer-parsed result to preserve all semantic values and types.
  • Run final metadata and asset validation against the consumer-parsed object.
  • Validate all four published channel files:
    • latest.yml
    • latest-mac.yml
    • latest-linux.yml
    • latest-linux-arm64.yml
  • Fail closed when:
    • the consumer parser is unavailable or incompatible;
    • metadata changes type during consumer parsing;
    • releaseDate is not a string before serialization.
  • Preserve compatibility with historical metadata by normalizing legacy Date values at the runtime boundary.
  • Tighten the internal upgrade event contract so releaseDate is always a string.
  • Cover persisted update-marker restoration with isolated real filesystem state.
  • Document the consumer-oracle contract, compatibility boundaries, and deferred risks.

Summary by CodeRabbit

  • Bug Fixes

    • Improved release metadata validation to prevent malformed or incompatible update information from being published.
    • Standardized release dates as ISO-formatted strings across update status events and release metadata.
    • Added fail-closed checks for invalid updater metadata, including incorrect field types and unavailable parsing support.
    • Improved recovery of persisted failed-update status, including restoration of status details and cleanup of the saved marker.
  • Documentation

    • Added specifications covering updater metadata validation, compatibility requirements, and update-marker recovery behavior.

Create and clean a real userData directory for every upgrade-service test.
Future marker writes can no longer fail behind the production error boundary.
Document the release parser and package-export assumptions.
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b5397ccf-716d-43a1-8561-cc4340702089

📥 Commits

Reviewing files that changed from the base of the PR and between ee5d423 and 18fdf59.

📒 Files selected for processing (7)
  • docs/issues/updater-metadata-consumer-validation/spec.md
  • scripts/ci/assemble-release.mjs
  • scripts/ci/updater-metadata-consumer.mjs
  • src/shared/contracts/events/upgrade.events.ts
  • test/main/routes/contracts.test.ts
  • test/main/scripts/releaseAssembly.test.ts
  • test/main/upgrade/upgradeService.test.ts

📝 Walkthrough

Walkthrough

The release pipeline now parses generated updater YAML with electron-updater, compares consumer-parsed metadata with expected values, and enforces string releaseDate fields. Event contracts and tests cover normalized dates and persisted update-marker restoration.

Changes

Updater metadata validation

Layer / File(s) Summary
Consumer parser adapter and validation contract
scripts/ci/updater-metadata-consumer.mjs, docs/issues/updater-metadata-consumer-validation/spec.md
Loads electron-updater’s parser and rejects unavailable parsers or invalid consumer metadata mappings; documents the validation and serialization requirements.
Release metadata serialization and round-trip validation
scripts/ci/assemble-release.mjs, test/main/scripts/releaseAssembly.test.ts
Requires string release dates, quotes generated YAML values, compares consumer-parsed metadata with expected metadata, and validates all generated channel files.
Release-date event contract and marker restore coverage
src/shared/contracts/events/upgrade.events.ts, test/main/routes/contracts.test.ts, test/main/upgrade/upgradeService.test.ts
Restricts event releaseDate values to strings and tests failed-update marker restoration, event emission, and marker removal.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: zerob13

Sequence Diagram(s)

sequenceDiagram
  participant ReleaseAssembly
  participant MetadataFile
  participant ElectronUpdater
  participant UpgradeEvents
  ReleaseAssembly->>MetadataFile: serialize quoted releaseDate YAML
  ReleaseAssembly->>ElectronUpdater: parse generated YAML bytes
  ElectronUpdater-->>ReleaseAssembly: return consumer metadata
  ReleaseAssembly->>ReleaseAssembly: compare values and types
  ReleaseAssembly->>UpgradeEvents: publish string releaseDate
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: validating updater metadata with the real consumer parser.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/updater-metadata-consumer-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yyhhyyyyyy
yyhhyyyyyy merged commit 95d0c27 into dev Jul 26, 2026
12 checks passed
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