hashicorp/nomad · error
Task name cannot include slashes
Error message
Task name cannot include slashes
What it means
Task.Validate rejects task names containing '/' or '\\' because the task name becomes a directory on disk under the allocation directory; slashes would create nested or invalid paths. The check uses strings.ContainsAny on the name.
Source
Thrown at nomad/structs/structs.go:8242
return fmt.Sprintf("*%#v", *t)
}
// Validate is used to check a task for reasonable configuration
func (t *Task) Validate(jobType string, tg *TaskGroup) error {
var mErr multierror.Error
if t.Name == "" {
mErr.Errors = append(mErr.Errors, errors.New("Missing task name"))
}
// Tasks cannot be named "alloc" as this conflicts with and breaks task
// filesystem isolation features.
if t.Name == "alloc" {
mErr.Errors = append(mErr.Errors, errors.New("Task cannot be named \"alloc\""))
}
if strings.ContainsAny(t.Name, `/\`) {
// We enforce this so that when creating the directory on disk it will
// not have any slashes.
mErr.Errors = append(mErr.Errors, errors.New("Task name cannot include slashes"))
} else if strings.Contains(t.Name, "\000") {
mErr.Errors = append(mErr.Errors, errors.New("Task name cannot include null characters"))
}
if t.Driver == "" {
mErr.Errors = append(mErr.Errors, errors.New("Missing task driver"))
}
if t.KillTimeout < 0 {
mErr.Errors = append(mErr.Errors, errors.New("KillTimeout must be a positive value"))
} else {
// Validate the group's update strategy does not conflict with the
// task's kill_timeout for service jobs.
//
// progress_deadline = 0 has a special meaning so it should not be
// validated against the task's kill_timeout.
conflictsWithProgressDeadline := jobType == JobTypeService &&
tg.Update != nil &&
tg.Update.ProgressDeadline > 0 &&
t.KillTimeout > tg.Update.ProgressDeadlineView on GitHub (pinned to 482b49bf1a)
Solutions
- Remove slashes from the task name (use "-" or "_" instead).
- Sanitize names in job-generation scripts.
- Validate before submit.
Example fix
// before
task "web/server" {
driver = "docker"
}
// after
task "web-server" {
driver = "docker"
} Defensive patterns
Strategy: validation
Validate before calling
if strings.ContainsAny(t.Name, `/\\`) {
return fmt.Errorf("task name %q must not contain slashes", t.Name)
} Type guard
func isPathSafeName(t *structs.Task) bool {
return !strings.ContainsAny(t.Name, `/\\`)
} Prevention
- Sanitize generated task names (replace / with -).
- Never derive task names from file paths or image names directly.
- Add name-pattern lint to job CI.
When it happens
Trigger: A task name containing a forward or back slash, e.g. task "web/server" or names derived from file paths or container image names.
Common situations: Deriving the task name from a repo path or image tag; Windows-style separators in generated configs.
Related errors
- Missing task name
- Task cannot be named "alloc"
- Task name cannot include null characters
- Missing task driver
- KillTimeout must be a positive value
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/d8d62153fcef3574.
Report an issue: GitHub.