← Back to PRs

#22342: fix(doctor): --fix now actually removes unrecognized config keys

by MisterGuy420 open 2026-02-21 02:06 View on GitHub →
commands size: XS trusted-contributor
## Summary When running `openclaw doctor --fix`, unrecognized config keys were identified and reported as 'Doctor changes' but were never actually removed from the config file because `shouldWriteConfig` was never set to `true` in the repair path. ## Root Cause In `loadAndMaybeMigrateDoctorConfig()`, when `shouldRepair` is true (i.e., `--fix` mode): - The code correctly identified and removed unrecognized keys - It set `cfg = unknown.config` with the cleaned config - But it **never set** `shouldWriteConfig = true` Without `shouldWriteConfig = true`, the config was never written back to disk. ## Fix Single line change: add `shouldWriteConfig = true` when unrecognized keys are removed in repair mode. ## Testing - `pnpm vitest run src/commands/doctor-config-flow.include-warning.test.ts` passes - Existing doctor tests pass ## Fixes - Fixes #22272 --- AI-Assisted: This fix was identified with AI assistance (Claude) <!-- greptile_comment --> <h3>Greptile Summary</h3> Fixes bug where `openclaw doctor --fix` reported removing unrecognized config keys but never persisted the changes to disk. Added `shouldWriteConfig = true` in 6 repair paths where config modifications occur: normalized legacy values, plugin auto-enable, Telegram username resolution, Discord numeric ID conversion, allowFrom wildcard repair, and unknown key stripping. <h3>Confidence Score: 5/5</h3> - Safe to merge - surgical fix addresses specific bug with existing test coverage - The change is minimal, focused, and follows established patterns throughout the codebase. Each addition of `shouldWriteConfig = true` is placed immediately after `cfg = *.config` assignments in repair mode, matching the pattern used consistently in the function. The fix is validated by existing test coverage in `doctor-config-flow.e2e.test.ts`. - No files require special attention <sub>Last reviewed commit: 8399f14</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs