Skip to content

loader: honor !reset on keys of fields normalized into KEY=VALUE sequences - #913

Draft
ndeloof wants to merge 1 commit into
compose-spec:mainfrom
ndeloof:reset-key-in-normalized-sequences
Draft

loader: honor !reset on keys of fields normalized into KEY=VALUE sequences#913
ndeloof wants to merge 1 commit into
compose-spec:mainfrom
ndeloof:reset-key-in-normalized-sequences

Conversation

@ndeloof

@ndeloof ndeloof commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

What

Fixes docker/compose#11816.

A !reset on a mapping key (environment.FOO, labels.x, …) records a key path, applied to the accumulated model before merging the file that carries it. But once two earlier files contributed the same field, merging has normalized the mapping into a sorted KEY=VALUE sequence (override.mergeToSequence), so applyNullOverrides's key-deletion branch finds a sequence it cannot address and the reset was silently ignored — which made the bug look like a mysterious three-file issue, while resetting the whole field kept working.

How

applyNullOverrides now translates such patterns: when a recorded path extends a sequence's path by exactly one segment, sequence entries whose key part matches are dropped — KEY=VALUE and bare KEY passthrough forms alike. Segments un-escape through tree.Path, so dotted keys (labels) match their raw entry form. Whole-field resets and the existing mapping-branch behavior are untouched.

The regression test covers a key from the first file, a key contributed in sequence form by a second file, a bare passthrough key, and a dotted label key — while checking untargeted entries survive.

🤖 Generated with Claude Code

…ences

A `!reset` on a mapping key (environment.FOO, labels.x, …) is recorded as
a key path, then applied to the accumulated model before merging the file
that carries it. But once two earlier files contributed the same field,
merging has normalized the mapping into a sorted "KEY=VALUE" sequence
(override.mergeToSequence), so the key-deletion branch of
applyNullOverrides finds a sequence it cannot address and the reset was
silently ignored. Resetting a whole field kept working; per-key resets
only failed once a second file touched the field, which made the bug look
like a mysterious three-file issue.

Teach applyNullOverrides to translate such patterns: when a recorded path
extends a sequence's path by exactly one segment, drop the entries whose
key part matches — "KEY=VALUE" and bare "KEY" passthrough forms alike.
Path segments un-escape through tree.Path so dotted keys (labels) match
their raw entry form.

Fixes docker/compose#11816

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
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.

[BUG] !reset tag does not work on environment keys when multiple files contibute

1 participant