{"id":"9f732fadcfeffbd8","repo":"go-redis/redis","slug":"circuit-breaker-failure-threshold-must-be-1","errorCode":null,"errorMessage":"circuit breaker failure threshold must be >= 1","messagePattern":"circuit breaker failure threshold must be >= 1","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"maintnotifications/errors.go","lineNumber":71,"sourceCode":"\tErrConnectionInvalidHandoffState = errors.New(logs.ConnectionInvalidHandoffStateErrorMessage)\n)\n\n// shutdown errors\nvar (\n\t// ErrShutdown is returned when the maintnotifications manager is shutdown\n\tErrShutdown = errors.New(logs.ShutdownError())\n)\n\n// circuit breaker errors\nvar (\n\t// ErrCircuitBreakerOpen is returned when the circuit breaker is open\n\tErrCircuitBreakerOpen = errors.New(logs.CircuitBreakerOpenErrorMessage)\n)\n\n// circuit breaker configuration errors\nvar (\n\t// ErrInvalidCircuitBreakerFailureThreshold is returned when the circuit breaker failure threshold is invalid\n\tErrInvalidCircuitBreakerFailureThreshold = errors.New(logs.InvalidCircuitBreakerFailureThresholdError())\n\t// ErrInvalidCircuitBreakerResetTimeout is returned when the circuit breaker reset timeout is invalid\n\tErrInvalidCircuitBreakerResetTimeout = errors.New(logs.InvalidCircuitBreakerResetTimeoutError())\n\t// ErrInvalidCircuitBreakerMaxRequests is returned when the circuit breaker max requests is invalid\n\tErrInvalidCircuitBreakerMaxRequests = errors.New(logs.InvalidCircuitBreakerMaxRequestsError())\n)\n","sourceCodeStart":53,"sourceCodeEnd":77,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/maintnotifications/errors.go#L53-L77","documentation":"Returned by Config.Validate() (maintnotifications/config.go:178-180) when Config.CircuitBreakerFailureThreshold < 1. This threshold is the number of handoff failures to an endpoint required to open its circuit breaker (circuit_breaker.go:145). At least one failure must be required, otherwise the breaker could never open.","triggerScenarios":"Setting Options.MaintNotificationsConfig.CircuitBreakerFailureThreshold to 0 or a negative value, then constructing the client (Validate runs).","commonSituations":"Setting it to 0 intending to 'disable' the breaker (it does not — it just fails validation); computing it from a ratio that underflows; copy-pasting a stale config.","solutions":["Set CircuitBreakerFailureThreshold to >=1 (default is 5).","To make the breaker very sensitive, use a low positive value like 1-3, never 0.","Clamp externally sourced values to a minimum of 1 before assigning."],"exampleFix":"// before\ncfg := &maintnotifications.Config{CircuitBreakerFailureThreshold: 0}\n\n// after\ncfg := &maintnotifications.Config{CircuitBreakerFailureThreshold: 5}","handlingStrategy":"validation","validationCode":"if cfg.CircuitBreakerFailureThreshold < 1 {\n    cfg.CircuitBreakerFailureThreshold = 5\n}\nif err := cfg.Validate(); err != nil {\n    return fmt.Errorf(\"maint config: %w\", err)\n}","typeGuard":"func validFailureThreshold(n int) bool { return n >= 1 }","tryCatchPattern":null,"preventionTips":["Never set FailureThreshold to 0 to 'disable' the breaker.","Clamp config-sourced values to >=1.","Validate the full maint config in tests."],"tags":["maintnotifications","config","validation","circuit-breaker"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}