cli: validate COMPOSE_FILE entries point to actual compose files - #909
Open
ndeloof wants to merge 1 commit into
Open
cli: validate COMPOSE_FILE entries point to actual compose files#909ndeloof wants to merge 1 commit into
ndeloof wants to merge 1 commit into
Conversation
Entries set by the COMPOSE_FILE environment variable used to be resolved
to absolute paths with a bare os.Stat check, so an empty or directory
entry made the loader fail later with a cryptic OS-level error such as
"read <pwd>: is a directory" (an empty entry resolves to the working
directory).
Validate each entry when it is selected: it must be stdin ("-"), a
remote resource supported by a registered ResourceLoader, or a regular
local file. Errors now state how the file was selected:
compose file "" set by COMPOSE_FILE environment variable is invalid: /home/user is a directory
Config paths selected implicitly (COMPOSE_FILE, default file discovery)
are also tracked so read errors are decorated the same way, while
explicitly selected files (-f) keep a plain "compose file X is invalid"
prefix.
See docker/compose#13649
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
ndeloof
force-pushed
the
validate-compose-file-entries
branch
from
August 10, 2026 14:00
c1f716b to
2506f84
Compare
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.
Entries set by the
COMPOSE_FILEenvironment variable used to be resolved to absolute paths with a bareos.Stat, so an empty or directory entry made the loader fail later with a cryptic OS-level error such asread <pwd>: is a directory(an empty entry resolves to the working directory — see docker/compose#13649).Each entry is now validated when selected: it must be stdin (
-), a remote resource supported by a registeredResourceLoader, or a regular local file. Errors state how the file was selected:Implicitly selected config paths (
COMPOSE_FILE, default file discovery) are tracked so read errors get the same context, while explicitly selected files (-f) keep a plaincompose file X is invalidprefix.Side effect: remote resource references in
COMPOSE_FILEare no longer rejected by the localos.Statcheck (they still require an explicitCOMPOSE_PATH_SEPARATOR, as the default:conflicts with remote references).This contribution was prepared by an AI agent acting on the maintainer's behalf, then reviewed by them.