fix(interpolation): report all errors in a deterministic order - #903
Merged
ndeloof merged 2 commits intoJul 29, 2026
Merged
Conversation
ndeloof
approved these changes
Jul 29, 2026
ndeloof
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, with a proposal:
as interpolation always uses newPathError to produce error, we could use a custom error type which knows the path in error, and allows sorting by key (vs sorting by error string)
Interpolation used to stop at the first error, and Go's random map iteration made a different missing required variable surface on each run. Collect every interpolation error while walking the whole config instead, and sort the collected errors by message before joining them, so both the reported set and its order are stable across runs and users can fix all missing variables at once. Sorting only happens on the error path, which keeps the successful-interpolation hot path allocation-identical to the previous behavior. Fixes docker/compose#13712 Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
Address review feedback on compose-spec#903: carry the config path in a dedicated pathError type produced by newPathError, and sort collected errors by path segments instead of by formatted message. Errors now report in config-path order rather than grouped by message kind, and comparing segment-wise keeps sibling keys in key order when one is a prefix of another (e.g. "service" before "service-1"). As pathError unwraps its cause, InvalidTemplateError also becomes reachable through errors.As. Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
glours
force-pushed
the
interpolation-report-all-missing-variables
branch
from
July 29, 2026 12:59
b05f4e2 to
4aa9509
Compare
ndeloof
approved these changes
Jul 29, 2026
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.
Interpolation used to stop at the first error, and Go's random map iteration made a different missing required variable surface on each run.
Collect every interpolation error while walking the whole config instead, and sort the collected errors by message before joining them, so both the reported set and its order are stable across runs and users can fix all missing variables at once.
Sorting only happens on the error path, which keeps the successful-interpolation hot path allocation-identical to the previous behavior.
Fixes docker/compose#13712