Skip to content

fix(config): warn when service selection is silently ignored - #13950

Merged
glours merged 1 commit into
docker:mainfrom
glours:fix/config-warn-service-filtering
Jul 17, 2026
Merged

fix(config): warn when service selection is silently ignored#13950
glours merged 1 commit into
docker:mainfrom
glours:fix/config-warn-service-filtering

Conversation

@glours

@glours glours commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

What I did
docker compose config --no-interpolate <service> and docker compose config --variables <service> load the raw model without applying service filtering, so the full model is rendered regardless of the services passed as arguments. Filtering will not be supported on these paths, so emit a warning to make sure users are no longer misled by silently ignored arguments.

Related issue
Fixes #13614

(not mandatory) A picture of a cute animal, if possible in relation to what you did

`docker compose config --no-interpolate <service>` and
`docker compose config --variables <service>` load the raw model
without applying service filtering, so the full model is rendered
regardless of the services passed as arguments. Filtering will not
be supported on these paths, so emit a warning to make sure users
are no longer misled by silently ignored arguments.

Fixes docker#13614

Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 17, 2026 13:59
@glours
glours requested review from a team as code owners July 17, 2026 13:59
@glours
glours requested a review from ndeloof July 17, 2026 13:59
@glours glours self-assigned this Jul 17, 2026

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Assessment: 🟢 APPROVE

The change is small, correct, and well-tested. The two new logrus.Warn guards in runConfigNoInterpolate and runVariables accurately surface the silent-ignore behaviour described in the PR, and the accompanying E2E subtests validate both the warning text (stderr) and the expected output (stdout). No logic errors, resource leaks, missing error handling, or correctness issues were found in the added code.

@glours
glours enabled auto-merge (rebase) July 17, 2026 14:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds user-facing warnings to docker compose config when [SERVICE...] arguments are provided but are not applied for --no-interpolate and --variables, preventing silent misinterpretation of output (Fixes #13614).

Changes:

  • Emit warnings when service selection is provided for config --no-interpolate and config --variables, clarifying that the full model is rendered.
  • Add E2E coverage asserting the warning appears when a service name is passed with --no-interpolate / --variables.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
cmd/compose/config.go Adds warning logs for ignored service selectors in --no-interpolate and --variables code paths.
pkg/e2e/config_test.go Adds E2E tests expecting a warning on stderr when service selection is passed with --no-interpolate / --variables.

Comment thread cmd/compose/config.go
Comment on lines 269 to 275
func runConfigNoInterpolate(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) ([]byte, error) {
if len(services) > 0 {
logrus.Warn("service filtering is not applied when --no-interpolate is set, the full model will be rendered")
}
// we can't use ToProject, so the model we render here is only partially resolved
model, err := opts.ToModel(ctx, dockerCli, services)
if err != nil {
Comment thread pkg/e2e/config_test.go
Comment on lines +50 to +56
t.Run("--no-interpolate with service selection", func(t *testing.T) {
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/config/compose.yaml", "--project-name", projectName, "config", "--no-interpolate", "test")
res.Assert(t, icmd.Expected{
Err: "service filtering is not applied when --no-interpolate is set",
Out: `- ${PORT:-8080}:80`,
})
})
Comment thread pkg/e2e/config_test.go
Comment on lines +79 to +85
t.Run("--variables with service selection", func(t *testing.T) {
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/config/compose.yaml", "--project-name", projectName, "config", "--variables", "test")
res.Assert(t, icmd.Expected{
Err: "service filtering is not applied when --variables is set",
Out: `PORT`,
})
})
Comment thread cmd/compose/config.go
Comment on lines 525 to 530
func runVariables(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
if len(services) > 0 {
logrus.Warn("service filtering is not applied when --variables is set, variables from the full model will be rendered")
}
opts.noInterpolate = true
model, err := opts.ToModel(ctx, dockerCli, services, cli.WithoutEnvironmentResolution, cli.WithLoadOptions(loader.WithSkipValidation))
@glours
glours merged commit efb63f2 into docker:main Jul 17, 2026
43 of 45 checks passed
@glours
glours deleted the fix/config-warn-service-filtering branch July 17, 2026 14:12
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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] --no-interpolate flag on docker compose config has unexpected side effects

4 participants