{"record":{"id":"40f8c9706a18c3f3","repo":"hashicorp/nomad","slug":"missing-task-resources","errorCode":null,"errorMessage":"Missing task resources","messagePattern":"Missing task resources","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":8272,"sourceCode":"\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\n\t\tif conflictsWithProgressDeadline {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"KillTimout (%s) longer than the group's ProgressDeadline (%s)\",\n\t\t\t\tt.KillTimeout, tg.Update.ProgressDeadline))\n\t\t}\n\t}\n\tif t.ShutdownDelay < 0 {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"ShutdownDelay must be a positive value\"))\n\t}\n\n\t// Validate the resources.\n\tif t.Resources == nil {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Missing task resources\"))\n\t} else if err := t.Resources.Validate(); err != nil {\n\t\tmErr.Errors = append(mErr.Errors, err)\n\t}\n\n\t// Validate the log config\n\tif t.LogConfig == nil {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Missing Log Config\"))\n\t} else if err := t.LogConfig.Validate(tg.EphemeralDisk); err != nil {\n\t\tmErr.Errors = append(mErr.Errors, err)\n\t}\n\n\t// Validate constraints and affinities.\n\tfor idx, constr := range t.Constraints {\n\t\tif err := constr.Validate(); err != nil {\n\t\t\touter := fmt.Errorf(\"Constraint %d validation failed: %s\", idx+1, err)\n\t\t\tmErr.Errors = append(mErr.Errors, outer)\n\t\t}\n","sourceCodeStart":8254,"sourceCodeEnd":8290,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L8254-L8290","documentation":"Nomad's Task.Validate() collects all validation problems into a multierror. This error is appended when the Task struct has a nil Resources field. A task without a resources block cannot be scheduled because Nomad has no CPU/memory/network requirements to place it against, so validation fails before the job is accepted.","triggerScenarios":"Submitting (job register/plan) a job whose task stanza omits the resources block (or building a Task struct in Go with Resources left nil, e.g. via taskspec/template expansion that didn't populate Resources).","commonSituations":"Hand-writing HCL jobs and forgetting the resources stanza inside a task; programmatic job construction that skips defaulting; older API clients that predate resources being effectively mandatory; custom tooling generating jobs from templates that drop empty blocks.","solutions":["Add a resources stanza to the task with at least cpu and memory values.","If constructing the Task in Go, set t.Resources = &nomadstructs.Resources{CPU: ..., MemoryMB: ...} before calling Validate.","If the task is generated by tooling, fix the generator/template so the resources block is always emitted.","Run `nomad job validate <file>` before submitting to catch this client-side."],"exampleFix":"// before\ntask \"app\" {\n  driver = \"docker\"\n  config { image = \"nginx\" }\n}\n// after\ntask \"app\" {\n  driver = \"docker\"\n  config { image = \"nginx\" }\n  resources {\n    cpu    = 500\n    memory = 256\n  }\n}","handlingStrategy":"validation","validationCode":"func validateTaskResources(t *structs.Task) error {\n\tif t.Resources == nil {\n\t\treturn fmt.Errorf(\"task %q: resources stanza is required\", t.Name)\n\t}\n\tif t.Resources.CPU <= 0 || t.Resources.MemoryMB <= 0 {\n\t\treturn fmt.Errorf(\"task %q: cpu and memory must be positive\", t.Name)\n\t}\n\treturn nil\n}","typeGuard":"func hasResources(t *structs.Task) bool { return t != nil && t.Resources != nil }","tryCatchPattern":null,"preventionTips":["Always include a resources block in every task stanza, even minimal cpu/memory.","Run `nomad job validate job.hcl` in CI before any job submission.","In job-generation code, assert Tasks[i].Resources != nil before calling Validate."],"tags":["nomad","job-spec","validation","resources"],"backgroundTag":"missing-required-argument","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"}