{"record":{"id":"d8d62153fcef3574","repo":"hashicorp/nomad","slug":"task-name-cannot-include-slashes","errorCode":null,"errorMessage":"Task name cannot include slashes","messagePattern":"Task name cannot include slashes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":8242,"sourceCode":"\treturn fmt.Sprintf(\"*%#v\", *t)\n}\n\n// Validate is used to check a task for reasonable configuration\nfunc (t *Task) Validate(jobType string, tg *TaskGroup) error {\n\tvar mErr multierror.Error\n\tif t.Name == \"\" {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Missing task name\"))\n\t}\n\n\t// Tasks cannot be named \"alloc\" as this conflicts with and breaks task\n\t// filesystem isolation features.\n\tif t.Name == \"alloc\" {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Task cannot be named \\\"alloc\\\"\"))\n\t}\n\tif strings.ContainsAny(t.Name, `/\\`) {\n\t\t// We enforce this so that when creating the directory on disk it will\n\t\t// not have any slashes.\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Task name cannot include slashes\"))\n\t} else if strings.Contains(t.Name, \"\\000\") {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Task name cannot include null characters\"))\n\t}\n\tif t.Driver == \"\" {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Missing task driver\"))\n\t}\n\tif t.KillTimeout < 0 {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"KillTimeout must be a positive value\"))\n\t} else {\n\t\t// Validate the group's update strategy does not conflict with the\n\t\t// task's kill_timeout for service jobs.\n\t\t//\n\t\t// progress_deadline = 0 has a special meaning so it should not be\n\t\t// validated against the task's kill_timeout.\n\t\tconflictsWithProgressDeadline := jobType == JobTypeService &&\n\t\t\ttg.Update != nil &&\n\t\t\ttg.Update.ProgressDeadline > 0 &&\n\t\t\tt.KillTimeout > tg.Update.ProgressDeadline","sourceCodeStart":8224,"sourceCodeEnd":8260,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L8224-L8260","documentation":"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.","triggerScenarios":"A task name containing a forward or back slash, e.g. task \"web/server\" or names derived from file paths or container image names.","commonSituations":"Deriving the task name from a repo path or image tag; Windows-style separators in generated configs.","solutions":["Remove slashes from the task name (use \"-\" or \"_\" instead).","Sanitize names in job-generation scripts.","Validate before submit."],"exampleFix":"// before\ntask \"web/server\" {\n  driver = \"docker\"\n}\n// after\ntask \"web-server\" {\n  driver = \"docker\"\n}","handlingStrategy":"validation","validationCode":"if strings.ContainsAny(t.Name, `/\\\\`) {\n  return fmt.Errorf(\"task name %q must not contain slashes\", t.Name)\n}","typeGuard":"func isPathSafeName(t *structs.Task) bool {\n  return !strings.ContainsAny(t.Name, `/\\\\`)\n}","tryCatchPattern":null,"preventionTips":["Sanitize generated task names (replace / with -).","Never derive task names from file paths or image names directly.","Add name-pattern lint to job CI."],"tags":["nomad","task","naming","validation"],"backgroundTag":"invalid-task-name","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}