Skip to content

🐛 fix(config): propagate overrides through config references#3951

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
tales-aparecida:test-override
Jun 3, 2026
Merged

🐛 fix(config): propagate overrides through config references#3951
gaborbernat merged 2 commits into
tox-dev:mainfrom
tales-aparecida:test-override

Conversation

@tales-aparecida
Copy link
Copy Markdown
Contributor

@tales-aparecida tales-aparecida commented Jun 2, 2026

TOX_OVERRIDE (and the -x/--override flag) silently lost effect whenever it targeted a base value that another environment pulled in by reference. Overriding env_run_base.extras and then reading it from an environment that referenced that base returned the original file value, which defeated the common pattern of overriding shared configuration once and having every dependent environment inherit it — handy in CI pipelines and local scripts. 🔧

Overrides are normally applied inside Loader.load, but reference resolution reads values straight from the parsed config and never reaches that path, so the override was dropped. The fix folds any matching override back onto the raw value at the two places references resolve — the of form of a TOML {replace = "ref", ...} and the {[section]key} form in ini — through a shared helper that reads from a new Config.overrides view and infers the shape (list, dict, or scalar) from the value being overridden.

Both replacement (=) and append (+=) propagate now. The {replace = "ref", env = ..., key = ...} TOML form already worked because it resolves through a full environment load, so only the raw-read paths needed this. ⚠️ ini references are textual, so appending to a base value that sits inline with other tokens splices the appended item into that line — expected given how ini substitution works, and noted in the docs.

Fixes #3950.

Documents the issue where TOX_OVERRIDE does not propagate through
configuration references in both TOML and INI formats. When overriding
a base environment value that is later referenced, the override is
ignored and the original file value is used instead.

Tests currently assert the buggy behavior. Expected behavior is
documented in comments for when the issue is fixed.

Root cause: Reference resolution loads raw config values without
checking for overrides, bypassing the override system.

Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Tales da Aparecida <tales.aparecida@redhat.com>
@tales-aparecida tales-aparecida changed the title tests: add reproducers for TOX_OVERRIDE with config references draft: tests: add reproducers for TOX_OVERRIDE with config references Jun 2, 2026
@tales-aparecida
Copy link
Copy Markdown
Contributor Author

This is mostly a reproducer for #3950

@tales-aparecida tales-aparecida marked this pull request as draft June 2, 2026 19:44
@gaborbernat gaborbernat changed the title draft: tests: add reproducers for TOX_OVERRIDE with config references 🐛 fix(config): propagate overrides through config references Jun 3, 2026
@gaborbernat gaborbernat added bug:normal affects many people or has quite an impact area:configuration area:documentation labels Jun 3, 2026
TOX_OVERRIDE (and -x/--override) was ignored when overriding a base value
that is later referenced via {[section]key} (ini) or {replace = "ref",
of = [...]} (toml). Reference resolution reads raw values straight from the
parsed config, bypassing Loader.load() where overrides are applied.

Re-apply matching overrides onto the raw value at both reference-resolution
sites via a shared apply_overrides_to_raw helper, inferring the container
shape from the raw value. Flip the reproducer tests to assert the corrected
behavior and add a changelog entry plus docs.

Fixes tox-dev#3950
@tales-aparecida
Copy link
Copy Markdown
Contributor Author

Thanks for working on this!

@tales-aparecida tales-aparecida marked this pull request as ready for review June 3, 2026 19:52
@gaborbernat gaborbernat merged commit 9ac5479 into tox-dev:main Jun 3, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TOX_OVERRIDE does not propagate through config references when overriding a *base configuration*

2 participants