{"record":{"id":"9a2a824c426a2f60","repo":"hashicorp/nomad","slug":"healthydeadline-is-s-and-must-be-0","errorCode":null,"errorMessage":"HealthyDeadline is %s and must be >= 0","messagePattern":"HealthyDeadline is (.+?) and must be >= 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":6859,"sourceCode":"\t}\n\n\tswitch m.HealthCheck {\n\tcase MigrateStrategyHealthChecks, MigrateStrategyHealthStates:\n\t\t// ok\n\tcase \"\":\n\t\tif m.MaxParallel > 0 {\n\t\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"Missing HealthCheck\"))\n\t\t}\n\tdefault:\n\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"Invalid HealthCheck: %q\", m.HealthCheck))\n\t}\n\n\tif m.MinHealthyTime < 0 {\n\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"MinHealthyTime is %s and must be >= 0\", m.MinHealthyTime))\n\t}\n\n\tif m.HealthyDeadline < 0 {\n\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"HealthyDeadline is %s and must be >= 0\", m.HealthyDeadline))\n\t}\n\n\tif m.MinHealthyTime > m.HealthyDeadline {\n\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"MinHealthyTime must be less than HealthyDeadline\"))\n\t}\n\n\treturn mErr.ErrorOrNil()\n}\n\n// TaskGroup is an atomic unit of placement. Each task group belongs to\n// a job and may contain any number of tasks. A task group support running\n// in many replicas using the same configuration..\ntype TaskGroup struct {\n\t// Name of the task group\n\tName string\n\n\t// Count is the number of replicas of this task group that should\n\t// be scheduled.","sourceCodeStart":6841,"sourceCodeEnd":6877,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L6841-L6877","documentation":"MigrateStrategy.Validate rejects a negative HealthyDeadline. HealthyDeadline bounds how long the deployment waits for the minimum healthy allocations to appear; a negative deadline is invalid. Appended to the same multierror as the other strategy checks.","triggerScenarios":"Submitting a job with update block where healthy_deadline is negative (e.g. healthy_deadline = \"-1m\"), usually from templated or computed duration values gone wrong.","commonSituations":"Template math producing negative durations; sign typos in HCL; generated configs with bad defaults.","solutions":["Set healthy_deadline to a positive duration (e.g. \"5m\", the common default).","Fix the templating/computation that produced the negative value.","Omit the field to use Nomad's default if supported by your tooling.","Run `nomad job validate` before submit."],"exampleFix":"// before\nupdate {\n  healthy_deadline = \"-1m\"\n}\n// after\nupdate {\n  healthy_deadline = \"5m\"\n}","handlingStrategy":"validation","validationCode":"func validHealthyDeadline(m *structs.MigrateStrategy) error {\n\tif m.HealthyDeadline < 0 {\n\t\treturn fmt.Errorf(\"healthy_deadline must be >= 0, got %s\", m.HealthyDeadline)\n\t}\n\treturn nil\n}","typeGuard":"func hasNonNegativeHealthyDeadline(m *structs.MigrateStrategy) bool {\n\treturn m.HealthyDeadline >= 0\n}","tryCatchPattern":"if err := strategy.Validate(); err != nil {\n\tif strings.Contains(err.Error(), \"HealthyDeadline is\") {\n\t\t// reset healthy_deadline to a positive default like 5m\n\t}\n}","preventionTips":["Clamp computed deadlines to positive durations.","Review template math that scales healthy_deadline.","Keep explicit time units in job files.","Validate update blocks before submission."],"tags":["nomad","go","validation","migrate-strategy","duration"],"backgroundTag":"negative-duration-validation","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"}