{"record":{"id":"4f86a47197e4b44f","repo":"hashicorp/nomad","slug":"failures-before-warning-may-only-be-set-for-consul","errorCode":null,"errorMessage":"failures_before_warning may only be set for Consul service checks","messagePattern":"failures_before_warning may only be set for Consul service checks","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/services.go","lineNumber":400,"sourceCode":"\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}\n\tif err := sc.validateCommon(allowable); err != nil {\n\t\treturn err\n\t}\n\n\tcheckType := strings.ToLower(sc.Type)","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/services.go#L382-L418","documentation":"Service check validation in validateNomad: failures_before_warning was set on a Nomad-native check; this Consul-only field (warning threshold before critical) has no meaning for Nomad checks and is rejected.","triggerScenarios":"Setting failures_before_warning on a check of a non-Consul service.","commonSituations":"Consul check tuning carried into nomad services; shared check templates across providers.","solutions":["Remove failures_before_warning from the check","Move the service to provider = \"consul\" if warning-stage behavior is needed","Use on_update/ignore semantics or check_restart limits instead"],"exampleFix":"// before\ncheck {\n  failures_before_warning = 2\n}\n// after\ncheck {\n  on_update = \"ignore_warn\"\n}","handlingStrategy":"validation","validationCode":"if check.FailuresBeforeWarning != 0 && service.Provider != \"consul\" {\n    return fmt.Errorf(\"check %q: failures_before_warning requires consul provider\", check.Name)\n}","typeGuard":null,"tryCatchPattern":"if err := job.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"failures_before_warning\") {\n        // remove the field or move service to consul\n    }\n}","preventionTips":["Remember nomad checks have no warning state","Keep consul-only fields in consul provider templates only","Run nomad job validate in CI"],"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"}