mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:10:43 +00:00
fix: keep config recovery in doctor
This commit is contained in:
@@ -439,9 +439,9 @@ ls -lt "$CONFIG".rejected.* 2>/dev/null | head
|
||||
openclaw config validate
|
||||
```
|
||||
|
||||
Direct editor writes are still allowed, but the running Gateway treats them as untrusted until they validate. Invalid direct edits can be restored from the last-known-good backup during startup or hot reload. See [Gateway troubleshooting](/gateway/troubleshooting#gateway-restored-last-known-good-config).
|
||||
Direct editor writes are still allowed, but the running Gateway treats them as untrusted until they validate. Invalid direct edits fail startup or are skipped by hot reload; Gateway does not rewrite `openclaw.json`. Run `openclaw doctor --fix` to repair prefixed/clobbered config or restore the last-known-good copy. See [Gateway troubleshooting](/gateway/troubleshooting#gateway-rejected-invalid-config).
|
||||
|
||||
Whole-file recovery is reserved for globally broken config, such as parse errors, root-level schema failures, legacy migration failures, or mixed plugin and root failures. If validation fails only under `plugins.entries.<id>...`, OpenClaw keeps the active `openclaw.json` in place and reports the plugin-local issue instead of restoring `.last-good`. This prevents plugin schema changes or `minHostVersion` skew from rolling back unrelated user settings such as models, providers, auth profiles, channels, gateway exposure, tools, memory, browser, or cron config.
|
||||
Whole-file recovery is reserved for doctor repair. Plugin schema changes or `minHostVersion` skew stay loud instead of rolling back unrelated user settings such as models, providers, auth profiles, channels, gateway exposure, tools, memory, browser, or cron config.
|
||||
|
||||
## Subcommands
|
||||
|
||||
|
||||
@@ -104,10 +104,10 @@ is available, then fall back to `latest`.
|
||||
</Note>
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="Config includes and invalid-config recovery">
|
||||
<Accordion title="Config includes and invalid-config repair">
|
||||
If your `plugins` section is backed by a single-file `$include`, `plugins install/update/enable/disable/uninstall` write through to that included file and leave `openclaw.json` untouched. Root includes, include arrays, and includes with sibling overrides fail closed instead of flattening. See [Config includes](/gateway/configuration) for the supported shapes.
|
||||
|
||||
If config is invalid during install, `plugins install` normally fails closed and tells you to run `openclaw doctor --fix` first. During Gateway startup, invalid config for one plugin is isolated to that plugin so other channels and plugins can keep running; `openclaw doctor --fix` can quarantine the invalid plugin entry. The only documented install-time exception is a narrow bundled-plugin recovery path for plugins that explicitly opt into `openclaw.install.allowInvalidConfigRecovery`.
|
||||
If config is invalid during install, `plugins install` normally fails closed and tells you to run `openclaw doctor --fix` first. During Gateway startup and hot reload, invalid plugin config fails closed like any other invalid config; `openclaw doctor --fix` can quarantine the invalid plugin entry. The only documented install-time exception is a narrow bundled-plugin recovery path for plugins that explicitly opt into `openclaw.install.allowInvalidConfigRecovery`.
|
||||
|
||||
</Accordion>
|
||||
<Accordion title="--force and reinstall vs update">
|
||||
|
||||
@@ -89,17 +89,13 @@ When validation fails:
|
||||
- Run `openclaw doctor` to see exact issues
|
||||
- Run `openclaw doctor --fix` (or `--yes`) to apply repairs
|
||||
|
||||
The Gateway keeps a trusted last-known-good copy after each successful startup.
|
||||
If `openclaw.json` later fails validation (or drops `gateway.mode`, shrinks
|
||||
sharply, or has a stray log line prepended), OpenClaw preserves the broken file
|
||||
as `.clobbered.*`, restores the last-known-good copy, and logs the recovery
|
||||
reason. The next agent turn also receives a system-event warning so the main
|
||||
agent does not blindly rewrite the restored config. Promotion to last-known-good
|
||||
is skipped when a candidate contains redacted secret placeholders such as `***`.
|
||||
When every validation issue is scoped to `plugins.entries.<id>...`, OpenClaw
|
||||
does not perform whole-file recovery. It keeps the current config active and
|
||||
surfaces the plugin-local failure so a plugin schema or host-version mismatch
|
||||
cannot roll back unrelated user settings.
|
||||
The Gateway keeps a trusted last-known-good copy after each successful startup,
|
||||
but startup and hot reload do not restore it automatically. If `openclaw.json`
|
||||
fails validation (including plugin-local validation), Gateway startup fails or
|
||||
the reload is skipped and the current runtime keeps the last accepted config.
|
||||
Run `openclaw doctor --fix` (or `--yes`) to repair prefixed/clobbered config or
|
||||
restore the last-known-good copy. Promotion to last-known-good is skipped when a
|
||||
candidate contains redacted secret placeholders such as `***`.
|
||||
|
||||
## Common tasks
|
||||
|
||||
@@ -539,20 +535,15 @@ The Gateway watches `~/.openclaw/openclaw.json` and applies changes automaticall
|
||||
|
||||
Direct file edits are treated as untrusted until they validate. The watcher waits
|
||||
for editor temp-write/rename churn to settle, reads the final file, and rejects
|
||||
invalid external edits by restoring the last-known-good config. OpenClaw-owned
|
||||
config writes use the same schema gate before writing; destructive clobbers such
|
||||
as dropping `gateway.mode` or shrinking the file by more than half are rejected
|
||||
and saved as `.rejected.*` for inspection.
|
||||
invalid external edits without rewriting `openclaw.json`. OpenClaw-owned config
|
||||
writes use the same schema gate before writing; destructive clobbers such as
|
||||
dropping `gateway.mode` or shrinking the file by more than half are rejected and
|
||||
saved as `.rejected.*` for inspection.
|
||||
|
||||
Plugin-local validation failures are the exception: if all issues are under
|
||||
`plugins.entries.<id>...`, reload keeps the current config and reports the plugin
|
||||
issue instead of restoring `.last-good`.
|
||||
|
||||
If you see `Config auto-restored from last-known-good` or
|
||||
`config reload restored last-known-good config` in logs, inspect the matching
|
||||
`.clobbered.*` file next to `openclaw.json`, fix the rejected payload, then run
|
||||
`openclaw config validate`. See [Gateway troubleshooting](/gateway/troubleshooting#gateway-restored-last-known-good-config)
|
||||
for the recovery checklist.
|
||||
If you see `config reload skipped (invalid config)` or startup reports `Invalid
|
||||
config`, inspect the config, run `openclaw config validate`, then run `openclaw
|
||||
doctor --fix` for repair. See [Gateway troubleshooting](/gateway/troubleshooting#gateway-rejected-invalid-config)
|
||||
for the checklist.
|
||||
|
||||
### Reload modes
|
||||
|
||||
|
||||
@@ -300,9 +300,10 @@ Related:
|
||||
- [Configuration](/gateway/configuration)
|
||||
- [Doctor](/gateway/doctor)
|
||||
|
||||
## Gateway restored last-known-good config
|
||||
## Gateway rejected invalid config
|
||||
|
||||
Use this when the Gateway starts, but logs say it restored `openclaw.json`.
|
||||
Use this when Gateway startup fails with `Invalid config` or hot reload logs say
|
||||
it skipped an invalid edit.
|
||||
|
||||
```bash
|
||||
openclaw logs --follow
|
||||
@@ -313,19 +314,19 @@ openclaw doctor
|
||||
|
||||
Look for:
|
||||
|
||||
- `Config auto-restored from last-known-good`
|
||||
- `gateway: invalid config was restored from last-known-good backup`
|
||||
- `config reload restored last-known-good config after invalid-config`
|
||||
- A timestamped `openclaw.json.clobbered.*` file beside the active config
|
||||
- A main-agent system event that starts with `Config recovery warning`
|
||||
- `Invalid config at ...`
|
||||
- `config reload skipped (invalid config): ...`
|
||||
- `Config write rejected: ...`
|
||||
- A timestamped `openclaw.json.rejected.*` file beside the active config
|
||||
- A timestamped `openclaw.json.clobbered.*` file if `doctor --fix` repaired a broken direct edit
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="What happened">
|
||||
- The rejected config did not validate during startup or hot reload.
|
||||
- OpenClaw preserved the rejected payload as `.clobbered.*`.
|
||||
- The active config was restored from the last validated last-known-good copy.
|
||||
- The next main-agent turn is warned not to blindly rewrite the rejected config.
|
||||
- If all validation issues were under `plugins.entries.<id>...`, OpenClaw would not restore the whole file. Plugin-local failures stay loud while unrelated user settings remain in the active config.
|
||||
- The config did not validate during startup, hot reload, or an OpenClaw-owned write.
|
||||
- Gateway startup fails closed instead of rewriting `openclaw.json`.
|
||||
- Hot reload skips invalid external edits and keeps the current runtime config active.
|
||||
- OpenClaw-owned writes reject invalid/destructive payloads before commit and save `.rejected.*`.
|
||||
- `openclaw doctor --fix` owns repair. It can remove non-JSON prefixes or restore the last-known-good copy while preserving the rejected payload as `.clobbered.*`.
|
||||
|
||||
</Accordion>
|
||||
<Accordion title="Inspect and repair">
|
||||
@@ -338,16 +339,17 @@ Look for:
|
||||
```
|
||||
</Accordion>
|
||||
<Accordion title="Common signatures">
|
||||
- `.clobbered.*` exists → an external direct edit or startup read was restored.
|
||||
- `.clobbered.*` exists → doctor preserved a broken external edit while repairing the active config.
|
||||
- `.rejected.*` exists → an OpenClaw-owned config write failed schema or clobber checks before commit.
|
||||
- `Config write rejected:` → the write tried to drop required shape, shrink the file sharply, or persist invalid config.
|
||||
- `Rejected validation details:` → the recovery log or main-agent notice includes the schema path that caused the restore, such as `agents.defaults.execution` or `gateway.auth.password.source`.
|
||||
- `missing-meta-vs-last-good`, `gateway-mode-missing-vs-last-good`, or `size-drop-vs-last-good:*` → startup treated the current file as clobbered because it lost fields or size compared with the last-known-good backup.
|
||||
- `config reload skipped (invalid config):` → a direct edit failed validation and was ignored by the running Gateway.
|
||||
- `Invalid config at ...` → startup failed before Gateway services booted.
|
||||
- `missing-meta-vs-last-good`, `gateway-mode-missing-vs-last-good`, or `size-drop-vs-last-good:*` → an OpenClaw-owned write was rejected because it lost fields or size compared with the last-known-good backup.
|
||||
- `Config last-known-good promotion skipped` → the candidate contained redacted secret placeholders such as `***`.
|
||||
|
||||
</Accordion>
|
||||
<Accordion title="Fix options">
|
||||
1. Keep the restored active config if it is correct.
|
||||
1. Run `openclaw doctor --fix` to let doctor repair prefixed/clobbered config or restore last-known-good.
|
||||
2. Copy only the intended keys from `.clobbered.*` or `.rejected.*`, then apply them with `openclaw config set` or `config.patch`.
|
||||
3. Run `openclaw config validate` before restarting.
|
||||
4. If you edit by hand, keep the full JSON5 config, not just the partial object you wanted to change.
|
||||
|
||||
@@ -804,15 +804,15 @@ lives on the [First-run FAQ](/help/faq-first-run).
|
||||
|
||||
- OpenClaw-owned config writes validate the full post-change config before writing.
|
||||
- Invalid or destructive OpenClaw-owned writes are rejected and saved as `openclaw.json.rejected.*`.
|
||||
- If a direct edit breaks startup or hot reload, the Gateway restores the last-known-good config and saves the rejected file as `openclaw.json.clobbered.*`.
|
||||
- The main agent receives a boot warning after recovery so it does not blindly write the bad config again.
|
||||
- If a direct edit breaks startup or hot reload, Gateway fails closed or skips the reload; it does not rewrite `openclaw.json`.
|
||||
- `openclaw doctor --fix` owns repair and can restore last-known-good while saving the rejected file as `openclaw.json.clobbered.*`.
|
||||
|
||||
Recover:
|
||||
|
||||
- Check `openclaw logs --follow` for `Config auto-restored from last-known-good`, `Config write rejected:`, or `config reload restored last-known-good config`.
|
||||
- Check `openclaw logs --follow` for `Invalid config at`, `Config write rejected:`, or `config reload skipped (invalid config)`.
|
||||
- Inspect the newest `openclaw.json.clobbered.*` or `openclaw.json.rejected.*` beside the active config.
|
||||
- Keep the active restored config if it works, then copy only the intended keys back with `openclaw config set` or `config.patch`.
|
||||
- Run `openclaw config validate` and `openclaw doctor`.
|
||||
- Run `openclaw config validate` and `openclaw doctor --fix`.
|
||||
- Copy only the intended keys back with `openclaw config set` or `config.patch`.
|
||||
- If you have no last-known-good or rejected payload, restore from backup, or re-run `openclaw doctor` and reconfigure channels/models.
|
||||
- If this was unexpected, file a bug and include your last known config or any backup.
|
||||
- A local coding agent can often reconstruct a working config from logs or history.
|
||||
@@ -825,7 +825,7 @@ lives on the [First-run FAQ](/help/faq-first-run).
|
||||
- Use `config.patch` for partial RPC edits; keep `config.apply` for full-config replacement only.
|
||||
- If you are using the owner-only `gateway` tool from an agent run, it will still reject writes to `tools.exec.ask` / `tools.exec.security` (including legacy `tools.bash.*` aliases that normalize to the same protected exec paths).
|
||||
|
||||
Docs: [Config](/cli/config), [Configure](/cli/configure), [Gateway troubleshooting](/gateway/troubleshooting#gateway-restored-last-known-good-config), [Doctor](/gateway/doctor).
|
||||
Docs: [Config](/cli/config), [Configure](/cli/configure), [Gateway troubleshooting](/gateway/troubleshooting#gateway-rejected-invalid-config), [Doctor](/gateway/doctor).
|
||||
|
||||
</Accordion>
|
||||
|
||||
|
||||
@@ -99,11 +99,10 @@ If config is invalid, install normally fails closed and points you at
|
||||
`openclaw doctor --fix`. The only recovery exception is a narrow bundled-plugin
|
||||
reinstall path for plugins that opt into
|
||||
`openclaw.install.allowInvalidConfigRecovery`.
|
||||
During Gateway startup, invalid config for one plugin is isolated to that plugin:
|
||||
startup logs the `plugins.entries.<id>.config` issue, skips that plugin during
|
||||
load, and keeps other plugins and channels online. Run `openclaw doctor --fix`
|
||||
to quarantine the bad plugin config by disabling that plugin entry and removing
|
||||
its invalid config payload; the normal config backup keeps the previous values.
|
||||
During Gateway startup, invalid plugin config fails closed like any other invalid
|
||||
config. Run `openclaw doctor --fix` to quarantine the bad plugin config by
|
||||
disabling that plugin entry and removing its invalid config payload; the normal
|
||||
config backup keeps the previous values.
|
||||
When a channel config references a plugin that is no longer discoverable but the
|
||||
same stale plugin id remains in plugin config or install records, Gateway startup
|
||||
logs warnings and skips that channel instead of blocking every other channel.
|
||||
|
||||
Reference in New Issue
Block a user