Repository navigation
cli: one project-resolution story — single name precedence, no swallowed load error, strict service validation - #14151
Conversation
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The PR is well-structured and implements the described behavior correctly:
- Name precedence (
--project-name>COMPOSE_PROJECT_NAME> model name) is applied consistently through the refactoredprojectOrNameandtoProjectName. - Error handling for explicit
--filefailures (hard error), missing files with env name (silent), and broken implicit files with env name (warning + fallback) is correct and clearly documented. validateServiceNamescorrectly handles the nil-project case (label-based mode has no manifest to validate against) and covers profile-disabled services as legitimate targets.- The removal of hand-rolled service checks in
ps.goandvolumes.gois safe:ToProjectservice-selection already rejects unknowns at load time when a model is available. - The new test file covers the full resolution matrix with
t.Context()and clearly-named subtests.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
ba06b79 to
6ccca66
Compare
|
Re-checked this PR's legitimacy given everything that's landed since it was opened (Aug 28) — it's still exactly the right fix (Q1/Q2.c/Q3 from #14074 are unaffected by the jobs work), but it needed reconciling with
Rebased onto current |
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
065922e to
a64fdf7
Compare
a64fdf7 to
5c16378
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
5c16378 to
2654d2f
Compare
c0221f1 to
bbd728c
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
glours
left a comment
There was a problem hiding this comment.
Two findings, see inline. The restart 'we*' regression should be fixed (or explicitly accepted) before merge.
bbd728c to
c3cb156
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
Lower-confidence findings (not posted inline)
- [low] cmd/compose/compose.go:395 —
validateServiceNamesreturns on first invalid service, leaving subsequent bad names unreported (confidence: unverified low; UX concern, command still fails) - [low] cmd/compose/ps.go:108 —
psnow silently accepts profile-disabled services rather than rejecting them (confidence: unverified low; likely intentional behaviour change, worth confirming)
c3cb156 to
bb32c74
Compare
c46317c to
bb32c74
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
bb32c74 to
4b29231
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
4b29231 to
0fc49fe
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
Lower-confidence findings (not posted inline)
-
[medium] cmd/compose/compose.go:352 —
name = p.Nameafter successful load may return normalized name instead of raw--project-namevalue (confidence: weak 52/100)When
--project-nameis given and an explicit compose file is set,projectOrNamestoresp.Name(compose-go's normalized form) whiletoProjectNamereturns the rawo.ProjectName. Commands using different resolution paths could operate on slightly different names if the user supplies an already-valid name the normalization is a no-op, reducing the practical risk.
0fc49fe to
12a2b86
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
…wed load error, strict service validation projectOrName and toProjectName resolved the project with opposite precedences, and projectOrName silently swallowed any load error when COMPOSE_PROJECT_NAME was set: a broken compose file sent stop, down, ps... into label-based reconstruction without a word — even when the file was named explicitly with --file. One precedence now, documented on both resolvers and applied identically by compose-go while loading: --project-name, then COMPOSE_PROJECT_NAME, then the model's name. The failure policy becomes explicit: an unreadable explicit --file is a hard error; no file around with COMPOSE_PROJECT_NAME set stays the silent file-less workflow; a present-but-broken implicit file falls back to label-based mode with a warning. Service-name validation follows one rule — strict whenever a model is available: restart and wait no longer silently no-op on a typo (validateServiceNames, profile-disabled services remain legitimate targets), and the hand-rolled checks in ps and volumes are removed as dead code, the load-time selection already rejecting unknown names (pinned by test). Epic docker#14074, F.4. Rebased onto main, which since merged the jobs work (docker#14093, docker#14234): projectOrName's job-target detection (jobTargetErr) is restored ahead of the new explicit-file hard-error branch -- the file loaded fine here, only the target's selection failed -- and validateServiceNames now checks project.AllJobs() too, since restart/wait route their service arguments through it instead of projectOrName's own selection. docker-agent review: the "compose file found but could not be loaded" warning's suppression guard only matched errdefs.IsNotFoundError (compose-go's own ErrNotFound sentinel) -- a raw os.ErrNotExist (e.g. a nonexistent --project-directory) wasn't recognized and would have printed a misleading warning. Added errors.Is(err, os.ErrNotExist) as a fallback, and TestProjectOrNameResolution now asserts the warning's presence/absence in both directions instead of just the fallback name. COMPOSE_FILE counts as an explicit file, like --file (explicitFile(): process environment or .env, as compose-go reads it): it is loaded even with --project-name (docker#14535, also addressed by docker#14540), and failing to load it is a hard error rather than a label-based fallback. Consistent with docker#14540's reading of COMPOSE_FILE as the environment equivalent of -f. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
12a2b86 to
bd0f265
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Epic #14074, F.4, per the agreed behavior:
One name precedence (Q1), documented on both resolvers and applied identically by compose-go while loading:
--project-name>COMPOSE_PROJECT_NAME> the model's name.projectOrNameandtoProjectNameused to disagree.Explicit failure policy (Q2.c) —
projectOrNameused to swallow any load error whenCOMPOSE_PROJECT_NAMEwas set, silently sendingstop/down/ps… into label-based reconstruction, even for an explicit--file:--fileorCOMPOSE_FILE(its environment equivalent, from the environment or.env; one sharedexplicitFile()), which is also loaded when--project-nameis set ([BUG]docker compose stopignoresCOMPOSE_FILEwhen-pis used, skippingpre_stophooks #14535, same reading as fix(cli): load the project from COMPOSE_FILE when -p is set #14540);COMPOSE_PROJECT_NAME→ the normal file-less workflow, silent;COMPOSE_PROJECT_NAME→ label-based fallback with a warning.Strict service validation whenever a model is available (Q3):
restartandwaitno longer silently no-op on a typo (profile-disabled services remain legitimate targets); the hand-rolled checks inps/volumesare removed as dead code — load-time selection already rejects unknown names (pinned by test).Behavioral changes:
restart/waiton an unknown service now error; a broken explicit--fileorCOMPOSE_FILEnow errors instead of silently falling back (-p x stopwith a staleCOMPOSE_FILEnow fails instead of working label-only); a broken implicit file now warns. Unit tests cover the full resolution matrix.🤖 Generated with Claude Code