#22501: fix(doctor): preserve logging config in doctor --fix
commands
size: XS
Cluster:
Doctor and Memory Health Checks
Fixes #19432
The `openclaw doctor --fix` command was incorrectly removing the valid `logging` configuration section from `openclaw.json`, treating it as an "unknown config key".
## Changes
- Added `preservedKeys` set in `stripUnknownConfigKeys()` function
- Known valid config keys (like `logging`) are now preserved during the fix process
## Testing
1. Add logging config to openclaw.json:
```json
"logging": {
"file": "/path/to/gateway.log",
"redactSensitive": "tools"
}
```
2. Run `openclaw doctor --fix`
3. Verify logging section is preserved
---
This is my first contribution to OpenClaw. Please let me know if any adjustments are needed!
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added a `preservedKeys` set to prevent `openclaw doctor --fix` from removing the valid `logging` configuration section. The fix ensures that known valid config keys like `logging` are preserved during the config repair process, preventing data loss during doctor operations.
<h3>Confidence Score: 4/5</h3>
- Safe to merge with minor consideration about hardcoded approach
- The fix correctly addresses the reported issue by preserving the `logging` config key. However, the hardcoded `preservedKeys` set approach may need expansion if other valid config keys face the same issue in the future. The `logging` key is confirmed to be valid in the OpenClawSchema (zod-schema.ts:160-192), so this fix is functionally correct.
- No files require special attention
<sub>Last reviewed commit: e601c6b</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22408: fix: doctor --fix now persists config when removing unrecognized keys
by astroclaw · 2026-02-21
86.5%
#22342: fix(doctor): --fix now actually removes unrecognized config keys
by MisterGuy420 · 2026-02-21
85.0%
#21240: fix: GH#20607 prevent doctor from dropping custom config sections
by theognis1002 · 2026-02-19
82.1%
#11602: fix(config): skip stale legacy config files when openclaw.json exists
by akoscz · 2026-02-08
79.6%
#18546: fix(doctor): replace deprecated `auth add` command reference
by Phineas1500 · 2026-02-16
78.4%
#23432: Doctor: prevent permissive secret file modes during --fix
by bmendonca3 · 2026-02-22
78.0%
#22524: fix(doctor): preserve precision of large Discord snowflake IDs in -...
by jmasson · 2026-02-21
77.1%
#22327: fix(doctor): use gateway health status for memory search key check
by therk · 2026-02-21
76.7%
#17026: fix(doctor): handle invalid session file paths gracefully
by Limitless2023 · 2026-02-15
75.6%
#15903: fix(doctor): stricter gateway service detection to prevent false po...
by Shuai-DaiDai · 2026-02-14
75.3%