{"record":{"id":"f8e95730a84e363f","repo":"hashicorp/nomad","slug":"service-s-s-or-check-s-must-specify-task-par","errorCode":null,"errorMessage":"Service [%s]->%s or Check %s must specify task parameter","messagePattern":"Service \\[(.+?)\\]->(.+?) or Check (.+?) must specify task parameter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7595,"sourceCode":"\tif providerSet.Size() > 1 {\n\t\tmErr.Errors = append(mErr.Errors,\n\t\t\terrors.New(\"Multiple service providers used: task group services must use the same provider\"))\n\t}\n\n\treturn mErr.ErrorOrNil()\n}\n\n// validateScriptChecksInGroupServices ensures group-level services with script\n// checks know what task driver to use. Either the service.task or service.check.task\n// parameter must be configured.\nfunc (tg *TaskGroup) validateScriptChecksInGroupServices() error {\n\tvar mErr multierror.Error\n\tfor _, service := range tg.Services {\n\t\tif service.TaskName == \"\" {\n\t\t\tfor _, check := range service.Checks {\n\t\t\t\tif check.Type == \"script\" && check.TaskName == \"\" {\n\t\t\t\t\tmErr.Errors = append(mErr.Errors,\n\t\t\t\t\t\tfmt.Errorf(\"Service [%s]->%s or Check %s must specify task parameter\",\n\t\t\t\t\t\t\ttg.Name, service.Name, check.Name,\n\t\t\t\t\t\t))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn mErr.ErrorOrNil()\n}\n\n// validateScalingPolicy ensures that the scaling policy has consistent\n// min and max, not in conflict with the task group count\nfunc (tg *TaskGroup) validateScalingPolicy(j *Job) error {\n\tif tg.Scaling == nil {\n\t\treturn nil\n\t}\n\n\tvar mErr multierror.Error\n","sourceCodeStart":7577,"sourceCodeEnd":7613,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7577-L7613","documentation":"A task group service or its script check has no task defined. Script checks execute inside a task's filesystem/allocation, so Nomad must know which task to run the check in; task-level services inherit the parent task's name, but group-level services must set `task` explicitly when they contain a script check.","triggerScenarios":"Declaring a group-level `service` (which has no implicit task) whose `check` has `type = \"script\"` and no `task` field set in either the service or the check.","commonSituations":"Moving a service from task-level to group-level in Nomad 0.12+ and forgetting that the implicit task name is lost; adding a script check copied from a task-level example into a group-level service.","solutions":["Set `task = \"<taskname>\"` on the group-level service block","Or set `task` directly on the script check","Or move the service back to task-level where the task is implicit"],"exampleFix":"// before\ngroup \"app\" {\n  service {\n    name = \"app\"\n    check { type = \"script\" command = \"/bin/health\" }\n  }\n}\n// after\ngroup \"app\" {\n  service {\n    name = \"app\"\n    task = \"server\"\n    check { type = \"script\" command = \"/bin/health\" }\n  }\n}","handlingStrategy":"validation","validationCode":"for _, svc := range group.Services {\n  if svc.TaskName == \"\" {\n    for _, c := range svc.Checks {\n      if c.Type == \"script\" && c.TaskName == \"\" {\n        return fmt.Errorf(\"script check %q needs a task\", c.Name)\n      }\n    }\n  }\n}","typeGuard":"func scriptCheckHasTask(svc *api.Service) bool {\n  if svc.TaskName != \"\" { return true }\n  for _, c := range svc.Checks {\n    if c.Type == \"script\" && c.TaskName == \"\" { return false }\n  }\n  return true\n}","tryCatchPattern":null,"preventionTips":["Always set `task` explicitly on group-level services with script checks","Prefer http/tcp checks at group level; keep script checks task-level","Lint job files after moving services between group and task scope"],"tags":["nomad","job-validation","script-check"],"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"}