Repository navigation
loader: skip re-merge of identical resources imported through diamond includes - #906
Merged
ndeloof merged 1 commit intoAug 12, 2026
Merged
Conversation
… includes Since 3d3411d (compose-spec#835), importResource merges a re-imported resource into the already-imported definition unconditionally. When the same file is reached through multiple include paths, the identical definition is re-merged once per path, and list-valued extension fields (e.g. x-bake under build) get their entries appended per path: a service included through N paths ends with N copies of every extension list entry. Restore the pre-compose-spec#835 fast path: when the re-imported definition is deeply equal to the existing one, skip the merge. Genuinely different definitions keep the compose-spec#835 override-merge behavior. Signed-off-by: Davi De Castro Reis <davi@davi.eng.br>
ndeloof
enabled auto-merge (rebase)
August 11, 2026 15:04
ndeloof
disabled auto-merge
August 12, 2026 09:47
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 I did
Restored the identical-resource fast path in
importResourcethat #835 removed: when a resource re-imported through another include path is deeply equal to the already-imported definition, skip the merge. Genuinely different definitions keep the #835 override-merge behavior. Added a regression test with a diamond include fixture.Why
Since #835, a file reached through multiple
include:paths (a diamond) is re-merged once per path, and list-valued extension fields get their entries appended per re-merge — a service included through N paths ends with N copies of everyx-*list entry:docker compose config | grep -c 'example/cache:a'→ 1 on CLI v2.40.3 (compose-go v2.9.1), 2 on v5.0.0+/v2.10.0+; each additional include path adds another copy. Bisected to 3d3411d (#835). Spec-schema fields are unaffected (normalized downstream), which is why this went unnoticed.Real-world impact: a monorepo integration-test tree with ~60 include paths to shared services saw its resolved
configoutput grow from 2,043 to 127,725 cache entries (1.1 MB → 21 MB), and resolved output became dependent on which Docker Desktop version a developer runs.Testing
TestLoadWithDiamondIncludefails on master (2 != 1) and passes with the fix.go test ./loader/ ./override/pass.