fix: skip Agent configs that have nothing to migrate - #251
Open
yujiezhang-ops wants to merge 1 commit into
Open
yujiezhang-ops wants to merge 1 commit into
yujiezhang-ops wants to merge 1 commit into
Conversation
Every legacy migration renames an identifier OneAgent wrote, yet each config was parsed unconditionally on launch. OpenClaw's openclaw.json is JSON5, which hujson rejects (`invalid literal: models` for an unquoted key), so a user with no OneAgent history saw "无法迁移旧 BootAgent 配置" on every page. A file that never mentions oneagent is now left unread. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
On a Windows machine with OpenClaw installed, every page showed:
OpenClaw's config format is JSON5: this file has an unquoted top-level key (
models:) and a trailing comma. hujson only accepts JSONC, somigrateLegacyOpenClawfails before it can see the file has nooneagentprovider at all.MigrateLegacyAgentConfigsruns on every launch when~/.oneagentdoes not exist, so the notice comes back on every start.Every migration here renames an identifier OneAgent wrote (
oneagentkeys and prefixes,OneAgent -names).MigrateLegacyAgentConfigsnow skips any file that does not mentiononeagent(case-insensitive) without parsing it. A file that does mention it is parsed exactly as before, so a genuinely broken legacy config is still reported.Not in this PR
ReadOpenClawConfig(encoding/json) andWriteOpenClaw(loadJSON) also cannot read JSON5. With this file, OpenClaw status reports it as unreadable, and configuring OpenClaw from BootAgent would fail. That needs a JSON5 parser and a decision on how to write the file back, so it is left as a follow-up.Test plan
TestMigrateIgnoresAConfigWithNothingToMigrate: a JSON5 openclaw.json (unquoted key, trailing comma, no oneagent) returns nil and is left byte-identicalTestMigrateContinuesPastAFileItCannotParse: its broken file mentions oneagent, so it is still reportedgo test ./internal/config ./internal/appon Windows: same failure set asmain(22 pre-existing Unix-permission failures)🤖 Generated with Claude Code