{"record":{"id":"1d29fced7b9dabc5","repo":"hashicorp/nomad","slug":"invalid-initial-check-state-s-must-be-one-of","errorCode":null,"errorMessage":"invalid initial check state (%s), must be one of %q, %q, %q or empty","messagePattern":"invalid initial check state \\((.+?)\\), must be one of %q, %q, %q or empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/services.go","lineNumber":305,"sourceCode":"\t} else if sc.Interval < minCheckInterval {\n\t\treturn fmt.Errorf(\"interval (%v) cannot be lower than %v\", sc.Interval, minCheckInterval)\n\t}\n\n\t// validate timeout\n\tif sc.Timeout == 0 {\n\t\treturn fmt.Errorf(\"missing required value timeout. Timeout cannot be less than %v\", minCheckInterval)\n\t} else if sc.Timeout < minCheckTimeout {\n\t\treturn fmt.Errorf(\"timeout (%v) is lower than required minimum timeout %v\", sc.Timeout, minCheckInterval)\n\t}\n\n\t// validate the initial status\n\tswitch sc.InitialStatus {\n\tcase \"\":\n\tcase api.HealthPassing:\n\tcase api.HealthWarning:\n\tcase api.HealthCritical:\n\tdefault:\n\t\treturn fmt.Errorf(`invalid initial check state (%s), must be one of %q, %q, %q or empty`, sc.InitialStatus, api.HealthPassing, api.HealthWarning, api.HealthCritical)\n\t}\n\n\t// validate address_mode\n\tswitch sc.AddressMode {\n\tcase \"\", AddressModeHost, AddressModeDriver, AddressModeAlloc, AddressModeAllocIPv6:\n\t\t// Ok\n\tcase AddressModeAuto:\n\t\treturn fmt.Errorf(\"invalid address_mode %q - %s only valid for services\", sc.AddressMode, AddressModeAuto)\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid address_mode %q\", sc.AddressMode)\n\t}\n\n\t// validate on_update\n\tswitch sc.OnUpdate {\n\tcase \"\", OnUpdateIgnore, OnUpdateRequireHealthy, OnUpdateIgnoreWarn:\n\t\t// OK\n\tdefault:\n\t\treturn fmt.Errorf(\"on_update must be %q, %q, or %q; got %q\", OnUpdateRequireHealthy, OnUpdateIgnoreWarn, OnUpdateIgnore, sc.OnUpdate)","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/services.go#L287-L323","documentation":"Raised by ServiceCheck.validateCommon when a check's initial_status field is not one of the allowed Consul health states: passing, warning, critical, or the empty string. Nomad validates the value at job-registration time because it is forwarded to Consul as the check's starting state. Any other string causes the job to be rejected.","triggerScenarios":"Submitting a job with a check block containing initial_status = \"healthy\", \"ok\", \"PASSING\", or any value other than \"passing\"/\"warning\"/\"critical\"/empty, via nomad job run or the jobs API.","commonSituations":"Using synonyms like \"healthy\" or \"ok\" instead of Consul's exact state names; capitalization mistakes (the comparison is case-sensitive); copying values from other orchestrators with different state vocabularies.","solutions":["Set initial_status to exactly \"passing\", \"warning\", or \"critical\" (lowercase)","Omit initial_status entirely (empty defaults to Consul's behavior)","Check for capitalization/whitespace in the HCL value","Run nomad job validate to confirm before submission"],"exampleFix":"// before\ncheck {\n  type           = \"http\"\n  path           = \"/health\"\n  initial_status = \"healthy\"\n}\n// after\ncheck {\n  type           = \"http\"\n  path           = \"/health\"\n  initial_status = \"passing\"\n}","handlingStrategy":"validation","validationCode":"// Go: whitelist valid initial_status values\nvar validInitialStatus = map[string]bool{\n\tnomadApi.HealthPassing: true, \"\": true,\n\tnomadApi.HealthWarning: true, nomadApi.HealthCritical: true,\n}\nif !validInitialStatus[check.InitialStatus] {\n\treturn fmt.Errorf(\"initial_status %q invalid; use passing|warning|critical or empty\", check.InitialStatus)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only lowercase \"passing\", \"warning\", \"critical\" for initial_status","Prefer omitting initial_status unless you specifically need a pre-state","Lint job files against Nomad's schema in CI","Run `nomad job validate` before every submit"],"tags":["nomad","service-check","config-validation","consul"],"backgroundTag":"invalid-enum-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"}