Skip to content

Validate project names for Docker Compose compatibility#1073

Merged
Soner (shyim) merged 3 commits into
mainfrom
claude/eager-sagan-Oobmr
May 29, 2026
Merged

Validate project names for Docker Compose compatibility#1073
Soner (shyim) merged 3 commits into
mainfrom
claude/eager-sagan-Oobmr

Conversation

@shyim
Copy link
Copy Markdown
Member

Summary

Add validation for project names to ensure they are compatible with Docker Compose's project naming requirements. Project names can only contain alphanumeric characters, dashes, and underscores, and must start with a letter or digit.

Changes

  • Added validateProjectName() function in cmd/project/project_create.go that validates project folder names against Docker Compose naming constraints using a regex pattern
  • Added composeProjectNameRegexp regex pattern that matches valid Docker Compose project names: ^[a-zA-Z0-9][a-zA-Z0-9_-]*$
  • Integrated validation at two points in the project creation flow:
    • In the interactive prompt when asking for project name
    • Before dependency checks in the main command execution
  • Added comprehensive test coverage in cmd/project/project_create_test.go with TestValidateProjectName() that validates:
    • Valid names: alphanumeric, dashes, underscores, paths with valid segments
    • Invalid names: umlauts, spaces, dots, special characters, names starting with dash/underscore, empty strings

Implementation Details

  • Validation only checks the final path element (via filepath.Base()) since Docker Compose derives the project name from the directory name
  • Error messages clearly explain the naming constraints to users
  • Validation happens early in the flow to provide immediate feedback before any project setup occurs

https://claude.ai/code/session_012ynH2shX6TQgW983qJztYu

Project creation now validates the project name against the rules for a
Docker Compose project name. Names containing umlauts, spaces, dots or
other characters that Docker Compose would silently strip or reject (it
only allows alphanumerics, dashes and underscores, starting with a letter
or digit) are now rejected up front, both in the interactive form and
when the name is passed as an argument.
@github-code-quality
Copy link
Copy Markdown

github-code-quality Bot commented May 29, 2026

Code Coverage Overview

Languages: Go

Go / code-coverage/go-test

The overall coverage in the branch remains at 50%, unchanged from the branch.

Show a code coverage summary of the most impacted files.
File eb5bdd5 9e941bc +/-
cmd/project/project_create.go 36% 40% +4%

Updated May 29, 2026 08:26 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@shyim Soner (shyim) marked this pull request as ready for review May 29, 2026 08:18
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0500280cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread cmd/project/project_create.go Outdated
Docker Compose requires project names to contain only lowercase letters,
digits, dashes and underscores and to start with a lowercase letter or
digit. The previous regex also accepted uppercase letters (e.g. MyShop),
which would later fail once the generated Docker setup runs from the
project directory. Tighten the regex to lowercase-only and treat uppercase
names as invalid.
The interactive create form now validates the project name as the user
types instead of only on submit. The input description switches to a
red-highlighted hint describing the allowed characters whenever the
current value is not a valid Docker Compose project name, and reverts to
the normal help text once it is valid. The allowed-character rule is
shared between this live hint and the submit-time validation error.
@shyim Soner (shyim) merged commit 3b17b01 into main May 29, 2026
5 checks passed
@shyim Soner (shyim) deleted the claude/eager-sagan-Oobmr branch May 29, 2026 08:37
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.

2 participants