Skip to content

SEP-1727: Guard deep_dict_update against self-merge to prevent list doubling - #1359

Open
yyyyyyyan with Copilot wants to merge 6 commits into
mainfrom
copilot/sep-1727-fix-doubling-lists-in-settings
Open

SEP-1727: Guard deep_dict_update against self-merge to prevent list doubling#1359
yyyyyyyan with Copilot wants to merge 6 commits into
mainfrom
copilot/sep-1727-fix-doubling-lists-in-settings

Conversation

Copilot AI commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

When the selected YAML profile is the base profile, YamlPrefixConfigSettingsSource passes the same dict object as both operands to deep_dict_update. Every list-valued leaf is concatenated with itself, doubling entries. Against sidecar/settings.yaml this prevents SEPSettings from constructing at all (duplicate resolution step validation error).

Changes

  • app/core/utils/dict.py: Added is identity guard at the top of deep_dict_update. When both operands are the same object, the merge is a no-op — correct because every branch (scalar reassign, dict recurse, list concat) is already idempotent except list concat. The guard runs on each recursive step, so nested YAML anchors shared between two otherwise-distinct profiles are also covered.
def deep_dict_update(main_dict, update_dict):
    if main_dict is update_dict:
        return
    ...
  • tests/app/core/utils/test_dict.py: Added test_deep_dict_update_self_merge_is_noop — passes the same dict as both arguments and asserts lists are not doubled.
  • tests/app/core/test_config.py: Added test_yaml_prefix_config_settings_source_base_profile — selects the base profile through YamlPrefixConfigSettingsSource and asserts the resulting data matches the declared block exactly. Added a list field to the mock_yaml_data fixture to exercise the doubling path.

…oubling

Co-authored-by: yyyyyyyan <24644216+yyyyyyyan@users.noreply.github.com>
Copilot AI changed the title [WIP] SEP-1727: Fix doubling of lists in base settings profile SEP-1727: Guard deep_dict_update against self-merge to prevent list doubling Aug 18, 2026
Copilot AI requested a review from yyyyyyyan August 18, 2026 01:32
@yyyyyyyan
yyyyyyyan marked this pull request as ready for review August 18, 2026 02:07
Copilot AI lite review requested due to automatic review settings August 18, 2026 02:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a configuration-loading edge case where YamlPrefixConfigSettingsSource can pass the same dict as both operands to deep_dict_update, causing list-valued leaves to be concatenated with themselves (doubling entries) and potentially preventing SEPSettings construction.

Changes:

  • Add an identity (is) guard to deep_dict_update to make self-merges a no-op.
  • Add a unit test ensuring deep_dict_update(d, d) does not double lists.
  • Add a config-source regression test ensuring selecting the base YAML profile does not double list values.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
app/core/utils/dict.py Adds a self-merge guard to prevent list doubling during recursive merges.
tests/app/core/utils/test_dict.py Adds regression coverage for self-merge behavior in deep_dict_update.
tests/app/core/test_config.py Adds regression coverage for base-profile selection in YamlPrefixConfigSettingsSource and exercises list handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/app/core/test_config.py Outdated
Comment thread tests/app/core/utils/test_dict.py
Comment thread app/core/utils/dict.py Outdated
@yyyyyyyan yyyyyyyan added the qa passed Tests for this PR are completed and successful. label Aug 18, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…cstring

Co-authored-by: yyyyyyyan <24644216+yyyyyyyan@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  app/core/utils
  dict.py
  app/sep
  inventory.py
  app/sep/sync/syncers
  pmm.py
Project Total  

This report was generated by python-coverage-comment-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python qa passed Tests for this PR are completed and successful.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants