{"record":{"id":"2991e8830098a362","repo":"hashicorp/nomad","slug":"check-s-invalid-refers-to-non-existent-task-s","errorCode":null,"errorMessage":"Check %s invalid: refers to non-existent task %s","messagePattern":"Check (.+?) invalid: refers to non-existent task (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7549,"sourceCode":"\t\t\touter := fmt.Errorf(\"Service[%d] %s validation failed: %s\", i, service.Name, err)\n\t\t\tmErr.Errors = append(mErr.Errors, outer)\n\t\t\t// we break here to avoid the risk of crashing on null-pointer\n\t\t\t// access in a later step, accepting that we might miss out on\n\t\t\t// error messages to provide the user.\n\t\t\tcontinue\n\t\t}\n\t\tif service.AddressMode == AddressModeDriver {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"service %q cannot use address_mode=\\\"driver\\\", only services defined in a \\\"task\\\" block can use this mode\", service.Name))\n\t\t}\n\n\t\tfor _, check := range service.Checks {\n\t\t\tif check.TaskName != \"\" {\n\t\t\t\tif check.AddressMode == AddressModeDriver {\n\t\t\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Check %q invalid: cannot use address_mode=\\\"driver\\\", only checks defined in a \\\"task\\\" service block can use this mode\", service.Name))\n\t\t\t\t}\n\t\t\t\tif !taskSet.Contains(check.TaskName) {\n\t\t\t\t\tmErr.Errors = append(mErr.Errors,\n\t\t\t\t\t\tfmt.Errorf(\"Check %s invalid: refers to non-existent task %s\", check.Name, check.TaskName))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Produce an error of any services which are not unique enough in the group\n\t// i.e. have same <task, name, port>\n\tif idDuplicateSet.Size() > 0 {\n\t\tmErr.Errors = append(mErr.Errors,\n\t\t\tfmt.Errorf(\n\t\t\t\t\"Services are not unique: %s\",\n\t\t\t\tidDuplicateSet.StringFunc(\n\t\t\t\t\tfunc(u unique) string {\n\t\t\t\t\t\ts := u.task + \"->\" + u.name\n\t\t\t\t\t\tif u.port != \"\" {\n\t\t\t\t\t\t\ts += \":\" + u.port\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn s","sourceCodeStart":7531,"sourceCodeEnd":7567,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7531-L7567","documentation":"Service check validation error: the check's task-level reference (e.g. a Consul check task name) points at a task that does not exist in the job's task group, so Nomad cannot resolve where to run the check.","triggerScenarios":"A check specifies task = \"foo\" while the group defines no task named 'foo' (typo, removed task, or task defined in a different group); surfaced during group validation.","commonSituations":"Renaming or deleting a task without updating checks that reference it; typos in the task name; cross-group references, which Nomad does not allow.","solutions":["Correct the check's task name to match an existing task in the same group.","Remove the task field if the check should target the service's own task.","Re-add or rename the referenced task if it was removed by mistake."],"exampleFix":"// before\ncheck \"c\" { task=\"wev\" }\n// after\ncheck \"c\" { task=\"web\" }","handlingStrategy":"validation","validationCode":"tasks := map[string]bool{\"web\":true,\"api\":true}\nfor _, c := range svc.Checks {\n  if c.TaskName != \"\" && !tasks[c.TaskName] {\n    return fmt.Errorf(\"check %q: unknown task %q\", c.Name, c.TaskName)\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate check task references from the same variable as the task name","Rename tasks via search-and-replace across the whole job file","Ensure checks only reference tasks in the same group"],"tags":["nomad","check","validation","reference"],"backgroundTag":"nonexistent-task-reference","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"}