#21124: fix(config): preserve missing keys from original in restoreRedactedValues
size: XS
Cluster:
Config Redaction Improvements
## Problem
When Mac App calls `config.set`, keys present in original config but missing from incoming (e.g., `gateway.auth`) were being silently dropped.
## Root Cause
`restoreRedactedValuesWithLookup()` and `restoreRedactedValuesGuessing()` only iterate over `incoming` keys, not preserving keys from `original` that don't exist in `incoming`.
## Fix
After iterating incoming keys, also copy keys from original that don't exist in incoming. This preserves:
- Top-level keys (like `gateway.auth`)
- Nested keys (recursive functions apply the fix at each level)
## Testing
Added 2 regression tests covering both lookup and guessing code paths.
Fixes #21009
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixed silent data loss when Mac App calls `config.set` with partial config updates. The `restoreRedactedValuesWithLookup()` and `restoreRedactedValuesGuessing()` functions only iterated over keys present in the incoming config, causing keys from the original config (like `gateway.auth`) to be dropped if they weren't in the incoming update.
The fix adds a final loop in both functions to copy any keys from the original that don't exist in the incoming config, preserving the complete configuration across partial updates. This works at each recursion level, ensuring both top-level and nested keys are preserved.
- Added comprehensive regression tests covering both code paths (with and without `uiHints`)
- Tests verify that missing keys are preserved while incoming changes are still applied
- Fix is minimal and maintains backward compatibility
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The fix is well-targeted, addressing a clear bug with a simple solution. The implementation correctly preserves missing keys from the original config at each recursion level. Tests comprehensively cover both code paths (with and without ConfigUiHints). The change is minimal and doesn't alter existing behavior for keys that are present in incoming configs.
- No files require special attention
<sub>Last reviewed commit: b133a56</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#11208: fix(config): prevent __OPENCLAW_REDACTED__ corruption on config writes
by janckerchen · 2026-02-07
79.8%
#16301: fix: preserve custom config keys during configure wizard
by superlowburn · 2026-02-14
76.3%
#13849: fix(configure): preserve custom config keys across wizard sections
by mcaxtr · 2026-02-11
76.2%
#19510: fix(config): preserve configured values on invalid config validatio...
by yash27-lab · 2026-02-17
75.2%
#3859: fix(macOS): keep Not configured from snapping back to remote (AI-as...
by innoiso · 2026-01-29
75.0%
#13960: fix(ui): preserve structured config validation error details
by constansino · 2026-02-11
74.9%
#16991: fix(config): add missing defaults to config snapshot path
by AI-Reviewer-QS · 2026-02-15
74.6%
#19115: fix(logging): improved redaction for config objects and unquoted keys
by Clawborn · 2026-02-17
74.6%
#12792: fix: exclude 'tokens' (plural) fields from config redaction
by jpaine · 2026-02-09
74.5%
#21240: fix: GH#20607 prevent doctor from dropping custom config sections
by theognis1002 · 2026-02-19
73.8%