Skip to content

fix(cli): repair legacy config before update channel switch - #77069

Merged
vincentkoc merged 5 commits into
mainfrom
fix-update-legacy-config
May 6, 2026
Merged

vincentkoc merged 5 commits into
mainfrom
fix-update-legacy-config

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Summary

  • Repair doctor-migratable legacy config before openclaw update --channel ... persists the requested channel.
  • Keep arbitrary invalid config fail-closed by revalidating the repaired candidate before writing.
  • Add regression coverage for legacy Slack/Telegram streaming config and record the user-facing fix in the changelog.

Verification

  • pnpm exec oxfmt --check --threads=1 src/cli/update-cli/update-command.ts src/cli/update-cli.test.ts
  • git diff --check
  • pnpm test:serial src/cli/update-cli.test.ts -- --reporter=verbose
  • pnpm changed:lanes --json
  • Testbox tbx_01kqrfq2750vn7gfz16xjm5zdf: OPENCLAW_TESTBOX=1 pnpm testbox:run --id tbx_01kqrfq2750vn7gfz16xjm5zdf -- "pnpm check:changed" (GitHub Actions run 25299222649)

@vincentkoc vincentkoc self-assigned this May 4, 2026
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels May 4, 2026
@clawsweeper

clawsweeper Bot commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge.

Summary
This PR adds an update CLI preflight that migrates doctor-migratable legacy Slack/Telegram streaming config before persisting a requested update channel, plus regression coverage and a changelog entry.

Reproducibility: yes. Source inspection shows current main rejects openclaw update --channel ... when the snapshot is invalid, and the PR test models a doctor-migratable Slack/Telegram legacy config; the new dry-run regression is also source-reproducible from the PR line order.

Next step before merge
This is a draft PR with the protected maintainer label, so the existing branch should be handled by the maintainer/author rather than queued as an automated repair lane.

Security
Cleared: The diff only imports existing local repair and validation modules and changes config-write sequencing plus tests/changelog; no new dependency, workflow, secret, or supply-chain surface was introduced.

Review findings

  • [P2] Keep dry runs from repairing config — src/cli/update-cli/update-command.ts:1832-1836
Review details

Best possible solution:

Keep the legacy repair path, but make --dry-run preview-only for both migration and channel persistence, with regression coverage that asserts no config write occurs in that mode.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection shows current main rejects openclaw update --channel ... when the snapshot is invalid, and the PR test models a doctor-migratable Slack/Telegram legacy config; the new dry-run regression is also source-reproducible from the PR line order.

Is this the best way to solve the issue?

No. The repair direction is narrow and maintainable, but it currently runs before opts.dryRun; the safer fix is to skip the write during dry-run or compute a non-mutating preview candidate.

Full review comments:

  • [P2] Keep dry runs from repairing config — src/cli/update-cli/update-command.ts:1832-1836
    The new repair call runs before the existing if (opts.dryRun) branch. With a doctor-migratable invalid config, openclaw update --channel beta --dry-run now reaches replaceConfigFile through maybeRepairLegacyConfigForUpdateChannel, even though the update docs promise dry-run does not write config. Gate this repair behind non-dry-run behavior or make it preview-only, and add a dry-run regression test.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.91

What I checked:

  • PR diff places repair before dry-run: The PR head calls maybeRepairLegacyConfigForUpdateChannel when --channel is present and the config snapshot is invalid at lines 1831-1837; that helper calls replaceConfigFile at lines 1604-1611, while the existing dry-run branch is later at line 1901. (src/cli/update-cli/update-command.ts:1832, 3ee9631f661e)
  • Dry-run contract: The public update CLI docs say --dry-run previews the update flow without writing config, installing, syncing plugins, or restarting. Public docs: docs/cli/update.md. (docs/cli/update.md:39, c52b5657a2e4)
  • Current-main failure path: Current main exits with 'Config is invalid; cannot set update channel' when --channel is provided and readConfigFileSnapshot returns invalid, so the PR is addressing a real source-visible blocker. (src/cli/update-cli/update-command.ts:1797, c52b5657a2e4)
  • Legacy issue detection path: readConfigFileSnapshot collects legacyIssues for invalid configs after validation fails, which is the signal the PR uses for doctor-migratable repair. (src/config/io.ts:1786, c52b5657a2e4)
  • Likely owner history: git blame and git log show Vincent Koc as the current-main author for persistRequestedUpdateChannel and the legacy config migration helper around the relevant lines. (src/cli/update-cli/update-command.ts:1511, 0362f64eacb4)

Likely related people:

  • vincentkoc: Current-main blame for the update channel persistence helper and the legacy config migration helper points to commit 0362f64 by Vincent Koc; this PR also comes from the same member, so routing back there is well supported by history. (role: recent maintainer and current-main owner; confidence: high; commits: 0362f64eacb4; files: src/cli/update-cli/update-command.ts, src/commands/doctor/shared/legacy-config-migrate.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against c52b5657a2e4.

@vincentkoc
vincentkoc force-pushed the fix-update-legacy-config branch from 3ee9631 to eb2270a Compare May 6, 2026 00:54
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: M and removed size: S labels May 6, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review May 6, 2026 00:54
@vincentkoc
vincentkoc merged commit fcf0561 into main May 6, 2026
117 of 120 checks passed
@vincentkoc
vincentkoc deleted the fix-update-legacy-config branch May 6, 2026 00:54
steipete pushed a commit that referenced this pull request May 6, 2026
* fix(cli): repair legacy config before update channel switch

* docs(changelog): note update channel legacy config repair

* fix(update): keep legacy config repair doctor-owned

* fix(update): keep dry runs read-only

* fix(update): avoid include-flattening legacy repair
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…#77069)

* fix(cli): repair legacy config before update channel switch

* docs(changelog): note update channel legacy config repair

* fix(update): keep legacy config repair doctor-owned

* fix(update): keep dry runs read-only

* fix(update): avoid include-flattening legacy repair
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
…#77069)

* fix(cli): repair legacy config before update channel switch

* docs(changelog): note update channel legacy config repair

* fix(update): keep legacy config repair doctor-owned

* fix(update): keep dry runs read-only

* fix(update): avoid include-flattening legacy repair
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
…#77069)

* fix(cli): repair legacy config before update channel switch

* docs(changelog): note update channel legacy config repair

* fix(update): keep legacy config repair doctor-owned

* fix(update): keep dry runs read-only

* fix(update): avoid include-flattening legacy repair
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant