{"record":{"id":"b77b2ad1139af9ae","repo":"hashicorp/nomad","slug":"failures-before-warning-not-supported-for-check-of","errorCode":null,"errorMessage":"failures_before_warning not supported for check of type %q","messagePattern":"failures_before_warning not supported for check of type %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/services.go","lineNumber":456,"sourceCode":"\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 {\n\tswitch sc.Type {\n\tcase ServiceCheckGRPC, ServiceCheckHTTP, ServiceCheckTCP:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/services.go#L438-L474","documentation":"validateConsul found a positive failures_before_warning (or failures_before_critical) value on a check type outside the supported tcp/http/grpc set; threshold features only apply to those check types.","triggerScenarios":"Setting FailuresBeforeWarning > 0 on a check whose Type is not tcp/http/grpc during Consul validation.","commonSituations":"Template-generated check blocks applying warning thresholds to script or ttl checks.","solutions":["Remove the failures threshold fields from non-tcp/http/grpc checks","Switch the check type to tcp, http, or grpc if thresholds are needed"],"exampleFix":"// before\ncheck {\n  type = \"script\"\n  failures_before_warning = 1\n}\n// after\ncheck {\n  type = \"http\"\n  failures_before_warning = 1\n}","handlingStrategy":"validation","validationCode":"var passFail = []string{\"tcp\",\"http\",\"grpc\"}\nif sc.FailuresBeforeWarning > 0 && !slices.Contains(passFail, sc.Type) {\n    return fmt.Errorf(\"failures_before_warning unsupported for type %q\", sc.Type)\n}","typeGuard":"func canUseFailuresBeforeWarning(sc *ServiceCheck) bool {\n    return sc.FailuresBeforeWarning == 0 || slices.Contains([]string{\"tcp\",\"http\",\"grpc\"}, sc.Type)\n}","tryCatchPattern":null,"preventionTips":["Keep warning thresholds out of script/ttl checks","Centralize check construction in helpers that enforce type constraints"],"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"}