{"record":{"id":"21ff9f74c918a0f6","repo":"hashicorp/nomad","slug":"killtimeout-must-be-a-positive-value","errorCode":null,"errorMessage":"KillTimeout must be a positive value","messagePattern":"KillTimeout must be a positive value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":8250,"sourceCode":"\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\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}","sourceCodeStart":8232,"sourceCodeEnd":8268,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L8232-L8268","documentation":"Task validation guard in Task.Validate: fires when a task's kill_timeout is zero or negative. Nomad requires a positive duration so the driver knows how long to wait after SIGTERM before force-killing the task. Non-fatal validation error returned to the job submitter; fix by setting kill_timeout to a positive duration (e.g. \"5s\").","triggerScenarios":"A task sets `kill_timeout = \"-30s\"` or a programmatically built task has a negative time.Duration in KillTimeout.","commonSituations":"Sign mistakes in HCL durations; arithmetic producing negative durations in generated configs.","solutions":["Set kill_timeout to a positive duration, e.g. kill_timeout = \"30s\".","Clamp negative durations to 0 (default) in generation code.","Validate before submit."],"exampleFix":"// before\ntask \"app\" {\n  kill_timeout = \"-30s\"\n}\n// after\ntask \"app\" {\n  kill_timeout = \"30s\"\n}","handlingStrategy":"validation","validationCode":"if t.KillTimeout < 0 {\n  return fmt.Errorf(\"task %q kill_timeout must be >= 0\", t.Name)\n}","typeGuard":"func isNonNegativeDuration(d time.Duration) bool {\n  return d >= 0\n}","tryCatchPattern":null,"preventionTips":["Use positive duration literals in HCL.","Clamp durations from arithmetic to >= 0.","Lint for '-' before duration values in job files.","Align kill_timeout with group progress_deadline to avoid the related conflict error."],"tags":["nomad","task","duration","validation"],"backgroundTag":"invalid-duration","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"}