Skip to content

cli: validate COMPOSE_FILE entries point to actual compose files - #909

Open
ndeloof wants to merge 1 commit into
compose-spec:mainfrom
ndeloof:validate-compose-file-entries
Open

cli: validate COMPOSE_FILE entries point to actual compose files#909
ndeloof wants to merge 1 commit into
compose-spec:mainfrom
ndeloof:validate-compose-file-entries

Conversation

@ndeloof

@ndeloof ndeloof commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Entries set by the COMPOSE_FILE environment variable used to be resolved to absolute paths with a bare os.Stat, 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 — see docker/compose#13649).

Each entry is now validated when selected: it must be stdin (-), a remote resource supported by a registered ResourceLoader, or a regular local file. Errors state how the file was selected:

compose file "" set by COMPOSE_FILE environment variable is invalid: /home/user is a directory

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 plain compose file X is invalid prefix.

Side effect: remote resource references in COMPOSE_FILE are no longer rejected by the local os.Stat check (they still require an explicit COMPOSE_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.

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
ndeloof force-pushed the validate-compose-file-entries branch from c1f716b to 2506f84 Compare August 10, 2026 14:00
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.

1 participant