Skip to content

fix(interpolation): report all errors in a deterministic order - #903

Merged
ndeloof merged 2 commits into
compose-spec:mainfrom
glours:interpolation-report-all-missing-variables
Jul 29, 2026
Merged

fix(interpolation): report all errors in a deterministic order#903
ndeloof merged 2 commits into
compose-spec:mainfrom
glours:interpolation-report-all-missing-variables

Conversation

@glours

@glours glours commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

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

@ndeloof ndeloof left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

glours added 2 commits July 29, 2026 14:59
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
glours force-pushed the interpolation-report-all-missing-variables branch from b05f4e2 to 4aa9509 Compare July 29, 2026 12:59
@ndeloof
ndeloof merged commit b3992fc into compose-spec:main Jul 29, 2026
8 checks passed
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] docker compose config --quiet produces non-deterministic result for required variables

2 participants