Skip to content

Handle nested overrides that collide with non-mapping values - #216

Open
Imkkey wants to merge 1 commit into
beetbox:mainfrom
Imkkey:fix-nested-leaf-overrides
Open

Imkkey wants to merge 1 commit into
beetbox:mainfrom
Imkkey:fix-nested-leaf-overrides

Conversation

@Imkkey

@Imkkey Imkkey commented Oct 13, 2026

Copy link
Copy Markdown

Fixes #215.

EnvSource(parse_yaml_docs=True) crashes when a nested environment variable overrides a leaf already present in a parent YAML mapping. The same collision affects nested dictionaries combined with dotted set_args keys.

For example, APP_DATABASE='{host: localhost, port: 5432}' and APP_DATABASE__PORT='5433' currently call 5432.update(5433).

Only merge when both leaf values are dictionaries; otherwise retain the more-specific value. This follows the existing parent-before-child ordering. Existing shallow mapping merges, key order, and set_args handling of omitted/None arguments remain unchanged.

Tests cover scalar, list, null and mapping collisions, both insertion orders, dictionary and Namespace arguments, preserved source inputs, and shallow mapping merge/order. Add an Unreleased changelog entry.

Validation on Python 3.12.14:

  • Before: 108 new regression cases fail; 25 new controls pass.
  • After: all 133 new cases and all 432 core tests pass.
  • Full suite: 433 passed, one pre-existing failure in test_bump_version_applies_sequential_changelog_updates. Clean baseline: 300 passed with the same failure, caused by the fixed September-length underline for an October date.
  • Ruff lint/format, full mypy with the CI Python 3.10 target, strict Sphinx HTML build, changelog formatting/lint, and git diff --check pass.

No other Python runtime or remote CI has been tested for this patch. Prepared and checked with OpenAI Codex assistance; draft for maintainer review.

@Imkkey
Imkkey marked this pull request as ready for review October 14, 2026 06:22

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested overrides of full-YAML environment mappings raise AttributeError

1 participant