loader: detect unsupported compose-file attributes - #927
Merged
ndeloof merged 3 commits intoSep 8, 2026
Merged
Conversation
docker/compose currently hand-maintains a blocklist of compose-file attributes it accepts but doesn't honor outside Swarm mode (deploy.mode, credential_spec, label_file, ports[].mode: host, cluster volumes, ...). Any new attribute compose-spec adds falls through silently until someone remembers to add a check downstream. WithUnsupportedAttributesCheck lets a caller supply tree.Path patterns (with an optional value predicate for cases like ports[].mode) and get every match reported once, after loading. compose-go has no built-in notion of "unsupported" — the pattern list stays entirely caller-supplied. Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
…ributes check Deny patterns alone reproduce the problem they solve: every attribute the specification gains later falls through silently until someone adds a check. This layers the complementary allowlist onto UnsupportedAttributesCheck, sharing its walk and report: - Supported (or the composable WithSupportedAttributes option) declares the attribute paths the runtime implements; anything matching none of them is reported alongside the deny-pattern findings. Extension keys (x-*) and everything under them are exempt from this rule set (deny patterns still apply below them). - schema.AttributePaths derives the complete attribute-path inventory from the embedded JSON schema (pattern-keyed mappings as '*', sequence items as '[]', $ref cycles terminated, '^x-' pattern properties excluded, since a wildcard there would blanket-accept every undeclared sibling). A runtime builds its declaration by removing what it does not implement from the full specification. - tree.Matcher gives Path pattern sets a first-class matching API: exact Matches — declaring a path accepts that node only, so removing one leaf reliably surfaces it — plus MayContain for walkers that must know when a declared attribute lives deeper. Matching stays exact by design: subtree removal reports once at its root, leaf removal reports each leaf, and declared siblings keep the descent open. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
loader: fail-closed allowlist screening on top of the unsupported-attributes check
ndeloof
approved these changes
Sep 8, 2026
ndeloof
left a comment
Collaborator
There was a problem hiding this comment.
Deny patterns for the value-dependent cases, schema-derived allowlist for fail-closed exhaustiveness — one walk, one report. CI green, combined-usage covered by tests.
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.
Adds an opt-in
Options.UnsupportedAttributesCheckto the loader,combining two rule sets over one walk of the model:
Patterns/WithUnsupportedAttributesCheck):caller-supplied
tree.Pathpatterns for attributes known not to behonored, with an optional value predicate (e.g.
ports[].mode: host).Supported/WithSupportedAttributes): fail-closed —declare what the runtime supports, via
schema.AttributePaths()minuswhat's unimplemented. Anything else is reported, including attributes
the spec adds later.
x-*extensions are always exempt.New
tree.Matcher(Matches/MayContain) backs the allowlist matching.Groundwork for docker/compose#14196, replacing its hand-maintained
blocklist (docker/compose#13150)