Fix recursive_update_dict to add new keys from project config#26
Open
nulinspiratie wants to merge 5 commits into
Open
Fix recursive_update_dict to add new keys from project config#26nulinspiratie wants to merge 5 commits into
nulinspiratie wants to merge 5 commits into
Conversation
Previously, recursive_update_dict would skip keys that didn't exist in the base config, preventing project-specific configuration from adding new keys. This caused project overrides to be ignored when they introduced new configuration keys. Example bug scenario: - Base config: [quam] has version=3, no state_path - Project config: [quam] adds state_path="/project/path" - Result (before fix): state_path was SKIPPED - Result (after fix): state_path is ADDED The fix changes line 12 from "continue" to "to_update[k] = v; continue", ensuring new keys are added while preserving the existing recursive merge behavior for nested mappings.
Tests cover the specific bug scenario where project configs add new keys that don't exist in the base config. The key test case is test_recursive_update_dict_project_config_use_case which verifies the real-world scenario: - Base config has [quam] section with version, no state_path - Project config adds [quam].state_path - Result should include both base and project values Additional test cases cover: - Adding new keys at various nesting levels - Updating existing keys - Adding new top-level sections - Nested merging with mixed new/existing keys - Edge cases (empty updates, non-dict overrides) All tests pass with the fix in recursive_update_dict.
natangqm
reviewed
Dec 9, 2025
| @@ -10,6 +10,7 @@ def recursive_update_dict( | |||
| ) -> RawConfigType: | |||
There was a problem hiding this comment.
can you explain what this function is doing?
Contributor
Author
There was a problem hiding this comment.
Added docstring, does this clarify it?
Elad-Zaharan
reviewed
Dec 9, 2025
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
Fixes a bug in
recursive_update_dict()that prevented project-specific configuration from adding new keys that didn't exist in the base config.Problem
The
recursive_update_dict()function inqualibrate_config/core/utils.pywas skipping keys that didn't exist in the base dictionary:This caused project configuration overrides to be silently ignored when they tried to add new configuration keys.
Real-World Impact: QUAM State Path
This bug particularly affected QUAM's
state_pathconfiguration:Base config (
~/.qualibrate/config.toml):Project config (
~/.qualibrate/projects/CS_1/config.toml):Expected behavior: Project's
state_pathshould be merged into the final configActual behavior:
state_pathwas silently skipped, causing QUAM to not recognize project-specific state pathsUser Experience
When users switched projects and tried to load QUAM state:
This made project-based workflows impossible, as QUAM couldn't locate project-specific state files.
The Fix
Changed line 12 to add new keys instead of skipping them:
Testing
Verified the fix with:
state_pathBefore fix:
After fix:
Impact
Related Issues
This completes the fix for project-aware QUAM configuration, which also required removing the
@cachedecorator fromget_quam_config()in the QUAM repository.