loader: honor !reset on keys of fields normalized into KEY=VALUE sequences - #913
Draft
ndeloof wants to merge 1 commit into
Draft
loader: honor !reset on keys of fields normalized into KEY=VALUE sequences#913ndeloof wants to merge 1 commit into
!reset on keys of fields normalized into KEY=VALUE sequences#913ndeloof wants to merge 1 commit into
Conversation
…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>
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.
What
Fixes docker/compose#11816.
A
!reseton 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 sortedKEY=VALUEsequence (override.mergeToSequence), soapplyNullOverrides'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
applyNullOverridesnow 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=VALUEand bareKEYpassthrough forms alike. Segments un-escape throughtree.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