{"record":{"id":"8ee1f5870f431e78","repo":"hashicorp/nomad","slug":"grace-period-must-be-greater-than-or-equal-to-0-bu","errorCode":null,"errorMessage":"grace period must be greater than or equal to 0 but found %d","messagePattern":"grace period must be greater than or equal to 0 but found (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7830,"sourceCode":"\tif c.IgnoreWarnings != o.IgnoreWarnings {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nfunc (c *CheckRestart) Validate() error {\n\tif c == nil {\n\t\treturn nil\n\t}\n\n\tvar mErr multierror.Error\n\tif c.Limit < 0 {\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"limit must be greater than or equal to 0 but found %d\", c.Limit))\n\t}\n\n\tif c.Grace < 0 {\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"grace period must be greater than or equal to 0 but found %d\", c.Grace))\n\t}\n\n\treturn mErr.ErrorOrNil()\n}\n\nconst (\n\t// DefaultKillTimeout is the default timeout between signaling a task it\n\t// will be killed and killing it.\n\tDefaultKillTimeout = 5 * time.Second\n)\n\n// LogConfig provides configuration for log rotation\ntype LogConfig struct {\n\tMaxFiles      int\n\tMaxFileSizeMB int\n\tDisabled      bool\n}\n","sourceCodeStart":7812,"sourceCodeEnd":7848,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7812-L7848","documentation":"CheckRestart.Validate: the grace period (time between task restart and health checking) is negative. Grace durations must be zero or a positive duration string.","triggerScenarios":"Submitting a job with `check_restart { grace = \"-5s\" }` or a CheckRestart struct with Grace < 0.","commonSituations":"Parsing durations from config where sign is lost; copy-paste typos with a stray minus; templated durations computed as (now - later).","solutions":["Set `grace` to a positive duration string (e.g. \"90s\")","Remove `grace` to use the service default","Validate duration signs in your config pipeline before rendering"],"exampleFix":"// before\ncheck_restart { grace = \"-30s\" }\n// after\ncheck_restart { grace = \"30s\" }","handlingStrategy":"validation","validationCode":"if cr != nil && cr.Grace < 0 {\n  return fmt.Errorf(\"check_restart.grace must be >= 0, got %d\", cr.Grace)\n}","typeGuard":"func validGrace(cr *api.CheckRestart) bool {\n  return cr == nil || cr.Grace >= 0\n}","tryCatchPattern":null,"preventionTips":["Use time.ParseDuration on inputs and reject negatives","Never compute grace from subtraction that can go negative","Validate rendered HCL with `nomad job validate` before submit"],"tags":["nomad","check-restart","job-validation"],"backgroundTag":"invalid-argument-value","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"}