{"record":{"id":"96552ee971a35456","repo":"hashicorp/nomad","slug":"failures-before-critical-not-supported-for-check-o","errorCode":null,"errorMessage":"failures_before_critical not supported for check of type %q","messagePattern":"failures_before_critical not supported for check of type %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/services.go","lineNumber":450,"sourceCode":"\t\t}\n\t}\n\n\t// passFailCheckTypes are intersection of check types supported by both Consul\n\t// and Nomad when using the pass/fail check threshold features.\n\t//\n\t// Consul only.\n\tpassFailCheckTypes := []string{\"tcp\", \"http\", \"grpc\"}\n\n\tif sc.SuccessBeforePassing < 0 {\n\t\treturn fmt.Errorf(\"success_before_passing must be non-negative\")\n\t} else if sc.SuccessBeforePassing > 0 && !slices.Contains(passFailCheckTypes, sc.Type) {\n\t\treturn fmt.Errorf(\"success_before_passing not supported for check of type %q\", sc.Type)\n\t}\n\n\tif sc.FailuresBeforeCritical < 0 {\n\t\treturn fmt.Errorf(\"failures_before_critical must be non-negative\")\n\t} else if sc.FailuresBeforeCritical > 0 && !slices.Contains(passFailCheckTypes, sc.Type) {\n\t\treturn fmt.Errorf(\"failures_before_critical not supported for check of type %q\", sc.Type)\n\t}\n\n\tif sc.FailuresBeforeWarning < 0 {\n\t\treturn fmt.Errorf(\"failures_before_warning must be non-negative\")\n\t} else if sc.FailuresBeforeWarning > 0 && !slices.Contains(passFailCheckTypes, sc.Type) {\n\t\treturn fmt.Errorf(\"failures_before_warning not supported for check of type %q\", sc.Type)\n\t}\n\n\t// Arbitrary value, we could bump it if needed\n\tif len(sc.Notes) > 255 {\n\t\treturn fmt.Errorf(\"notes must not be longer than 255 characters\")\n\t}\n\n\treturn nil\n}\n\n// RequiresPort returns whether the service check requires the task has a port.\nfunc (sc *ServiceCheck) RequiresPort() bool {","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/services.go#L432-L468","documentation":"Like success_before_passing, FailuresBeforeCritical is only valid on pass/fail check types (tcp, http, grpc). Setting it > 0 on any other check type (script, ttl, etc.) is rejected with the unsupported type named.","triggerScenarios":"Setting FailuresBeforeCritical > 0 on a check with Type outside {tcp,http,grpc}, then validating the service.","commonSituations":"Same misconfiguration pattern as success_before_passing: shared check blocks templated across script/ttl and http checks.","solutions":["Remove failures_before_critical from non pass/fail checks","Switch the check type to tcp/http/grpc","Set failures_before_critical to 0"],"exampleFix":"// before\ncheck {\n  type = \"ttl\"\n  failures_before_critical = 3\n}\n// after\ncheck {\n  type = \"tcp\"\n  failures_before_critical = 3\n}","handlingStrategy":"validation","validationCode":"var passFail = []string{\"tcp\",\"http\",\"grpc\"}\nif sc.FailuresBeforeCritical > 0 && !slices.Contains(passFail, sc.Type) {\n    return fmt.Errorf(\"failures_before_critical unsupported for type %q\", sc.Type)\n}","typeGuard":"func canUseFailuresBeforeCritical(sc *ServiceCheck) bool {\n    return sc.FailuresBeforeCritical == 0 || slices.Contains([]string{\"tcp\",\"http\",\"grpc\"}, sc.Type)\n}","tryCatchPattern":null,"preventionTips":["Apply pass/fail knobs only to tcp/http/grpc checks","Run nomad job validate in CI"],"tags":["nomad","consul","service-check","validation"],"backgroundTag":"invalid-check-configuration","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"}