← Back to PRs

#21124: fix(config): preserve missing keys from original in restoreRedactedValues

by Marvae open 2026-02-19 18:00 View on GitHub →
size: XS
## 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