Skip to content

fix(compose): name the compose file in processFile errors - #14391

Closed
TDnorthgarden wants to merge 1 commit into
docker:mainfrom
TDnorthgarden:fix/publish-error-file-context
Closed

TDnorthgarden wants to merge 1 commit into
docker:mainfrom
TDnorthgarden:fix/publish-error-file-context

Conversation

@TDnorthgarden

Copy link
Copy Markdown
Contributor

Problem

createLayers and processExtends return processFile errors unwrapped.
A failure in any of the project's compose files — the ones pulled in
through extends included — reaches the user with no hint of which file
to fix:

$ docker compose publish
service "web": env_file is in flow style, which cannot be rewritten while preserving formatting

With several compose files in play, the user has to open each one to find
the offender.

Fix

Wrap the two processFile call sites (createLayers, processExtends)
with the file name:

failed to process compose file ./override.yaml: service "web": env_file is in flow style, ...

Suggested in the #14387 review.

createLayers and processExtends return processFile errors unwrapped, so
a failure in any of the project's compose files — the extended ones
included — reaches the user with no hint of which file to fix. Wrap the
two call sites with the file name.

Signed-off-by: Aucoto <tdnorthgarden@gmail.com>
@TDnorthgarden
TDnorthgarden requested review from a team as code owners October 26, 2026 11:53
@ndeloof

ndeloof commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Thanks @TDnorthgarden, the change itself is correct and consistent with the surrounding error messages (both processFile callers are covered, %w keeps errors.Is/errors.As, and processExtends doesn't double-wrap).

That said, this is the follow-up suggested in the review of #14387, and since #14387 is still under review there is little point in landing it separately. Could you fold this commit into #14387 and close this PR?

Two reasons for doing it there:

Two small things while you are at it: the description uses ./override.yaml whereas project.ComposeFiles holds absolute paths, and the PR template (related issue, AI tool used) isn't filled in.

@TDnorthgarden

Copy link
Copy Markdown
Contributor Author

Thanks @TDnorthgarden, the change itself is correct and consistent with the surrounding error messages (both processFile callers are covered, %w keeps errors.Is/errors.As, and processExtends doesn't double-wrap).

That said, this is the follow-up suggested in the review of #14387, and since #14387 is still under review there is little point in landing it separately. Could you fold this commit into #14387 and close this PR?

Two reasons for doing it there:

Two small things while you are at it: the description uses ./override.yaml whereas project.ComposeFiles holds absolute paths, and the PR template (related issue, AI tool used) isn't filled in.

Agreed — especially on the weak test: os.ReadFile already carries the path, so the old assertions passed regardless of the wrap. Folded into #14387 (df3f26d): the tests now use a real flow-style file, whose rejection does not name the file, so only the wrapped error satisfies the assertions. Closing this one as suggested.

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.

2 participants