fix: resolve compose project names consistently - #13468
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #13460 by ensuring Docker Compose “project name” resolution is consistent when creating/operating compose projects (especially when the compose file is selected from a path whose parent directory name isn’t a valid Compose project name).
Changes:
- Frontend: adds an optional “Name” input when the compose source is “path”, and updates validation to allow empty-but-validated names in that mode.
- Agent/backend: resolves a canonical compose project name (prefer compose-defined name, else normalized parent dir, else user fallback) and consistently passes it to compose commands via
--project-name. - Updates shared validation patterns and i18n messages for the new compose-name resolution/validation behavior.
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/views/container/compose/index.vue | Adds optional name input for path-based compose creation and conditional validation rules. |
| frontend/src/lang/modules/zh.ts | Adds helper text translation for compose name priority. |
| frontend/src/lang/modules/zh-Hant.ts | Adds helper text translation for compose name priority. |
| frontend/src/lang/modules/tr.ts | Adds helper text translation for compose name priority. |
| frontend/src/lang/modules/ru.ts | Adds helper text translation for compose name priority. |
| frontend/src/lang/modules/pt-br.ts | Adds helper text translation for compose name priority. |
| frontend/src/lang/modules/ms.ts | Adds helper text translation for compose name priority. |
| frontend/src/lang/modules/lo.ts | Adds helper text translation for compose name priority. |
| frontend/src/lang/modules/ko.ts | Adds helper text translation for compose name priority. |
| frontend/src/lang/modules/ja.ts | Adds helper text translation for compose name priority. |
| frontend/src/lang/modules/fa.ts | Adds helper text translation for compose name priority. |
| frontend/src/lang/modules/es-es.ts | Adds helper text translation for compose name priority. |
| frontend/src/lang/modules/en.ts | Adds helper text translation for compose name priority. |
| frontend/src/global/form-rules.ts | Aligns compose-name length validation with intended 1–256 character constraint. |
| agent/utils/re/re.go | Adds a reusable backend regex constant for Compose project name validation. |
| agent/utils/compose/compose.go | Threads optional --project-name through compose operations (up/down/config/image discovery). |
| agent/i18n/lang/zh.yaml | Adds new error messages related to compose project-name parsing/derivation/validation. |
| agent/i18n/lang/zh-Hant.yaml | Adds new error messages related to compose project-name parsing/derivation/validation. |
| agent/i18n/lang/tr.yaml | Adds new error messages related to compose project-name parsing/derivation/validation. |
| agent/i18n/lang/ru.yaml | Adds new error messages related to compose project-name parsing/derivation/validation. |
| agent/i18n/lang/pt-BR.yaml | Adds new error messages related to compose project-name parsing/derivation/validation. |
| agent/i18n/lang/ms.yaml | Adds new error messages related to compose project-name parsing/derivation/validation. |
| agent/i18n/lang/lo.yaml | Adds new error messages related to compose project-name parsing/derivation/validation. |
| agent/i18n/lang/ko.yaml | Adds new error messages related to compose project-name parsing/derivation/validation. |
| agent/i18n/lang/ja.yaml | Adds new error messages related to compose project-name parsing/derivation/validation. |
| agent/i18n/lang/fa.yaml | Adds new error messages related to compose project-name parsing/derivation/validation. |
| agent/i18n/lang/es-ES.yaml | Adds new error messages related to compose project-name parsing/derivation/validation. |
| agent/i18n/lang/en.yaml | Adds new error messages related to compose project-name parsing/derivation/validation. |
| agent/app/service/runtime_utils.go | Extends compose command builder to optionally include --project-name. |
| agent/app/service/container_compose.go | Implements compose project-name resolution and propagates it through create/test/update/operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 32 out of 32 changed files in this pull request and generated no new comments.
Suppressed comments (2)
frontend/src/views/container/compose/index.vue:614
optionalComposeNameRuleduplicates the Compose-name regex and error message that already exist inRules.composeName, which makes it easy for validations to drift over time. Prefer reusing the shared rule’svalidatorand only special-case the empty-string behavior forfrom === 'path'.
agent/app/service/container_compose.go:320parentNameis derived from the compose file’s parent directory and returned as the project name, but it isn’t validated against the Compose name constraints (notably the 1–256 length limit). If the directory name normalizes to a value that’s too long, subsequentdocker compose --project-name ...calls can fail. ValidateparentNamewithre.ComposeNamePattern(and fall back to the user-provided name / error) before using it.
if dirName == "" {
// Keep compatibility with callers that used name as both the directory and
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 32 out of 32 changed files in this pull request and generated no new comments.
Suppressed comments (2)
agent/app/service/container_compose.go:346
resolveComposeProjectNamereturnsparentNamewithout validating it against the same Compose name constraints used elsewhere. SinceparentNameis derived from a directory name, it can still end up too long (or otherwise invalid) forComposeNamePattern, which would later break--project-nameoperations and reintroduce name/record inconsistencies. ValidateparentNamebefore returning it and fall back to the user-provided name (or error) when it’s invalid.
if parentName != "" {
return parentName, nil
}
agent/app/service/container_compose.go:390
- The error message in
runComposeConfighardcodes "docker-compose" even when the configured command isdocker compose, which can mislead users when troubleshooting. Consider using a command-agnostic message (or include the configured command).
return nil, fmt.Errorf("docker-compose config failed, std: %s, err: %v", mergeComposeOutput(stdout, stderr), err)
}
643b856 to
faf3b47
Compare
Refs #13460