{"record":{"id":"2d2a892db4ed7e73","repo":"hashicorp/nomad","slug":"task-cannot-be-named-alloc","errorCode":null,"errorMessage":"Task cannot be named \"alloc\"","messagePattern":"Task cannot be named \"alloc\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":8237,"sourceCode":"\t\tt.Identity.Canonicalize()\n\t}\n}\n\nfunc (t *Task) GoString() string {\n\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","sourceCodeStart":8219,"sourceCodeEnd":8255,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L8219-L8255","documentation":"Task.Validate forbids naming a task \"alloc\" because it collides with the alloc/ directory used for shared allocation scratch space, breaking task filesystem isolation. The check is an exact match on t.Name.","triggerScenarios":"A task block named `alloc` in HCL/JSON, e.g. task \"alloc\" { ... }, submitted to a Nomad cluster.","commonSituations":"Naming a task after the allocation concept; generated configs using generic placeholder names.","solutions":["Rename the task to something else, e.g. task \"app\".","Update references to the task name (service names, templates, log references).","Re-validate the job."],"exampleFix":"// before\ntask \"alloc\" {\n  driver = \"exec\"\n}\n// after\ntask \"allocator\" {\n  driver = \"exec\"\n}","handlingStrategy":"validation","validationCode":"if t.Name == \"alloc\" {\n  return errors.New(\"'alloc' is a reserved task name\")\n}","typeGuard":"func isReservedName(t *structs.Task) bool {\n  return t.Name == \"alloc\"\n}","tryCatchPattern":null,"preventionTips":["Never name tasks after Nomad-internal directories (alloc).","Enforce naming conventions in job linting.","Document reserved names in team job templates."],"tags":["nomad","task","naming","validation"],"backgroundTag":"reserved-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"}