fix: doctor --fix auto-repairs dmPolicy="open" missing allowFrom wildcard#18544
Merged
steipete merged 3 commits intoopenclaw:mainfrom Feb 16, 2026
Merged
Conversation
…card When a channel is configured with dmPolicy="open" but without allowFrom: ["*"], the gateway rejects the config and exits. The error message suggests running "openclaw doctor --fix", but the doctor had no repair logic for this case. This adds a repair step that automatically adds "*" to allowFrom (or creates it) when dmPolicy="open" is set without the required wildcard. Handles both top-level and nested dm.allowFrom, as well as per-account configs. Co-Authored-By: Claude Opus 4.6 <[email protected]>
src/commands/doctor-config-flow.ts
Outdated
Comment on lines
+574
to
+578
| const ensureWildcard = ( | ||
| channelName: string, | ||
| account: Record<string, unknown>, | ||
| prefix: string, | ||
| ) => { |
Contributor
There was a problem hiding this comment.
Unused channelName parameter
The channelName parameter is declared but never referenced inside ensureWildcard — only prefix is used for the change messages. This will likely trigger a lint warning. Consider removing the unused parameter.
Suggested change
| const ensureWildcard = ( | |
| channelName: string, | |
| account: Record<string, unknown>, | |
| prefix: string, | |
| ) => { | |
| const ensureWildcard = ( | |
| account: Record<string, unknown>, | |
| prefix: string, | |
| ) => { |
If you remove the parameter here, update the call sites at lines 619 and 627 accordingly (drop the first argument).
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/commands/doctor-config-flow.ts
Line: 574:578
Comment:
**Unused `channelName` parameter**
The `channelName` parameter is declared but never referenced inside `ensureWildcard` — only `prefix` is used for the change messages. This will likely trigger a lint warning. Consider removing the unused parameter.
```suggestion
const ensureWildcard = (
account: Record<string, unknown>,
prefix: string,
) => {
```
If you remove the parameter here, update the call sites at lines 619 and 627 accordingly (drop the first argument).
How can I resolve this? If you propose a fix, please make it concise.Addresses review feedback — channelName was declared but only prefix was used for change messages. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
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
When a channel is configured with
dmPolicy: "open"but withoutallowFrom: ["*"], the gateway rejects the config and crashes on startup with:The error message tells users to run
openclaw doctor --fix, but the doctor has no repair logic for this case — it just reports the same error again.Changes
Adds
maybeRepairOpenPolicyAllowFrom()to the doctor's repair flow that:dmPolicy: "open"withoutallowFromcontaining"*"allowFromarray exists, appends"*"to itallowFromexists, createsallowFrom: ["*"]channels.X.allowFrom) and nested (channels.X.dm.allowFrom) pathschannels.X.accounts.Y.allowFrom)This also fixes the gateway startup crash, since the gateway runs doctor in best-effort mode before starting — with this fix, the doctor will auto-repair the config and the gateway will start successfully.
Reproduction
openclaw.json:openclaw gateway— crashes with config invalid erroropenclaw doctor --fix— reports the same error, doesn't fix itAfter this fix:
openclaw doctor --fixaddsallowFrom: ["*"]automaticallyopenclaw gatewaystarts successfully (doctor auto-repairs during startup)Testing
[AI-assisted] Created with Claude Code. Tested in production.
Greptile Summary
Adds auto-repair logic to
openclaw doctor --fixfor the case wheredmPolicy: "open"is set withoutallowFrom: ["*"], which causes the schema validator to reject the config and crash the gateway on startup. The newmaybeRepairOpenPolicyAllowFrom()function scans all channel configs (including per-account and nesteddm.allowFrompaths) and adds the required wildcard entry. The non-repair path (running doctor without--fix) now also detects this misconfiguration and suggests the fix command.requireOpenAllowFrom(checks bothaccount.dmPolicyandaccount.dm.policy)"*"to existing top-levelallowFrom, appending to nesteddm.allowFrom, or creating newallowFrom: ["*"]channelNameparameter in theensureWildcardhelperConfidence Score: 4/5
Last reviewed commit: 2151684
(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!