{"record":{"id":"25ffdddb27c7801a","repo":"hashicorp/nomad","slug":"failures-before-critical-may-only-be-set-for-consu","errorCode":null,"errorMessage":"failures_before_critical may only be set for Consul service checks","messagePattern":"failures_before_critical may only be set for Consul service checks","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/services.go","lineNumber":395,"sourceCode":"\t// address_mode=\"driver\" not yet supported on nomad\n\tif sc.AddressMode == \"driver\" {\n\t\treturn errors.New(\"address_mode = driver may only be set for Consul service checks\")\n\t}\n\n\tif sc.Type == \"http\" {\n\t\tif sc.Method != \"\" && !helper.IsMethodHTTP(sc.Method) {\n\t\t\treturn fmt.Errorf(\"method type %q not supported in Nomad http check\", sc.Method)\n\t\t}\n\t}\n\n\t// success_before_passing is consul only\n\tif sc.SuccessBeforePassing != 0 {\n\t\treturn errors.New(\"success_before_passing may only be set for Consul service checks\")\n\t}\n\n\t// failures_before_critical is consul only\n\tif sc.FailuresBeforeCritical != 0 {\n\t\treturn errors.New(\"failures_before_critical may only be set for Consul service checks\")\n\t}\n\n\t// failures_before_warning is consul only\n\tif sc.FailuresBeforeWarning != 0 {\n\t\treturn errors.New(\"failures_before_warning may only be set for Consul service checks\")\n\t}\n\n\t// tls_server_name is consul only\n\tif sc.TLSServerName != \"\" {\n\t\treturn errors.New(\"tls_server_name may only be set for Consul service checks\")\n\t}\n\n\treturn nil\n}\n\n// validate a Service's ServiceCheck in the context of the Consul provider.\nfunc (sc *ServiceCheck) validateConsul() error {\n\tallowable := []string{ServiceCheckGRPC, ServiceCheckTCP, ServiceCheckHTTP, ServiceCheckScript}","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/services.go#L377-L413","documentation":"failures_before_critical (tolerate N failures before marking critical) is Consul-only; validateNomad rejects nonzero values on nomad checks because the failure-lifecycle logic exists only in Consul check handling.","triggerScenarios":"Setting failures_before_critical on a check of a nomad-provider service.","commonSituations":"Copy-pasted Consul check stanzas; attempts to soften flaky checks on nomad services.","solutions":["Remove failures_before_critical from the check","Switch the service to provider = \"consul\" to keep the behavior","Adjust interval/timeout or check_restart limit instead"],"exampleFix":"// before\ncheck {\n  failures_before_critical = 3\n}\n// after\ncheck {\n  check_restart {\n    limit = 3\n  }\n}","handlingStrategy":"validation","validationCode":"if check.FailuresBeforeCritical != 0 && service.Provider != \"consul\" {\n    return fmt.Errorf(\"check %q: failures_before_critical requires consul provider\", check.Name)\n}","typeGuard":null,"tryCatchPattern":"if err := job.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"failures_before_critical\") {\n        // remove the field or use check_restart limit instead\n    }\n}","preventionTips":["Treat failures_before_* fields as consul-only","Use check_restart.limit for restart tolerance on nomad","Validate jobs before submit"],"tags":["nomad","consul","service-check","validation"],"backgroundTag":"unsupported-check-option","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"}