louislam/dockge · error · ValidationError
Stack name can only contain [a-z][0-9] _ - only
Error message
Stack name can only contain [a-z][0-9] _ - only
What it means
Stack.validate() enforces a naming policy for compose projects: the stack name must fully match /^[a-z0-9_-]+$/, i.e. lowercase letters, digits, underscore, and hyphen only. Docker Compose project names have the same restriction, so any other character (uppercase, spaces, dots, slashes) throws this ValidationError before the stack is saved. It is called from save().
Source
Thrown at backend/stack.ts:117
});
if (!res.stdout) {
return {};
}
return JSON.parse(res.stdout.toString());
}
get isManagedByDockge() : boolean {
return fs.existsSync(this.path) && fs.statSync(this.path).isDirectory();
}
get status() : number {
return this._status;
}
validate() {
// Check name, allows [a-z][0-9] _ - only
if (!this.name.match(/^[a-z0-9_-]+$/)) {
throw new ValidationError("Stack name can only contain [a-z][0-9] _ - only");
}
// Check YAML format
yaml.parse(this.composeYAML);
let lines = this.composeENV.split("\n");
// Check if the .env is able to pass docker-compose
// Prevent "setenv: The parameter is incorrect"
// It only happens when there is one line and it doesn't contain "="
if (lines.length === 1 && !lines[0].includes("=") && lines[0].length > 0) {
throw new ValidationError("Invalid .env format");
}
}
get composeYAML() : string {
if (this._composeYAML === undefined) {
try {View on GitHub (pinned to f809ae192b)
Solutions
- Rename the stack to lowercase alphanumerics with _ or - only, e.g. 'my-stack-1'.
- Normalize before saving: name.toLowerCase().trim().replace(/[^a-z0-9_-]/g, '-').
- Validate the name client-side against /^[a-z0-9_-]+$/ before calling save.
Example fix
// before stack.name = 'My Stack.app'; stack.save(); // after stack.name = 'my-stack-app'; stack.save();
Defensive patterns
Strategy: validation
Validate before calling
function isValidStackName(name) {
return typeof name === 'string' && /^[a-z0-9_-]+$/.test(name);
} Type guard
function isSafeName(v) { return typeof v === 'string' && /^[a-z0-9_-]+$/.test(v); } Try / catch
try {
stack.save();
} catch (e) {
if (e.message.includes('Stack name')) {
e.message = 'Use lowercase letters, digits, _ or - only';
throw e;
}
} Prevention
- Normalize names: lowercase, trim, replace invalid chars with '-'
- Validate against /^[a-z0-9_-]+$/ in UI before calling save
- Avoid deriving stack names from image names or paths with dots/slashes
When it happens
Trigger: Saving/renaming a stack whose name contains characters outside [a-z0-9_-] — e.g. 'MyStack', 'my stack', 'my.stack', or an empty string.
Common situations: Users typing display-style names with capitals or spaces in the UI; deriving stack names from directory paths or image names containing dots/slashes; copied names with trailing whitespace.
Related errors
- Invalid .env format
- Name must be a string
- Stack name must be a string
- Stack name and service name must be strings
- Invalid stackName or serviceName
AI-assisted analysis of louislam/dockge@f809ae192b (2026-08-31).
Data as JSON: /api/errors/d69634ea18633a44.
Report an issue: GitHub.