{"record":{"id":"fd08666057750724","repo":"App-vNext/Polly","slug":"value-must-be-greater-than-zero-fd0866","errorCode":null,"errorMessage":"Value must be greater than zero.","messagePattern":"Value must be greater than zero\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Polly/CircuitBreaker/AdvancedCircuitBreakerSyntax.cs","lineNumber":228,"sourceCode":"    /// <exception cref=\"ArgumentNullException\">Thrown when <paramref name=\"onBreak\"/> is <see langword=\"null\"/>.</exception>\n    /// <exception cref=\"ArgumentNullException\">Thrown when <paramref name=\"onReset\"/> is <see langword=\"null\"/>.</exception>\n    /// <exception cref=\"ArgumentNullException\">Thrown when <paramref name=\"onHalfOpen\"/> is <see langword=\"null\"/>.</exception>\n    /// <remarks>(see \"Release It!\" by Michael T. Nygard fi).</remarks>\n    public static CircuitBreakerPolicy AdvancedCircuitBreaker(\n        this PolicyBuilder policyBuilder,\n        double failureThreshold,\n        TimeSpan samplingDuration,\n        int minimumThroughput,\n        TimeSpan durationOfBreak,\n        Action<Exception, CircuitState, TimeSpan, Context> onBreak,\n        Action<Context> onReset,\n        Action onHalfOpen)\n    {\n        var resolutionOfCircuit = TimeSpan.FromTicks(AdvancedCircuitController<EmptyStruct>.ResolutionOfCircuitTimer);\n\n        if (failureThreshold <= 0)\n        {\n            throw new ArgumentOutOfRangeException(nameof(failureThreshold), \"Value must be greater than zero.\");\n        }\n\n        if (failureThreshold > 1)\n        {\n            throw new ArgumentOutOfRangeException(nameof(failureThreshold), \"Value must be less than or equal to one.\");\n        }\n\n        if (samplingDuration < resolutionOfCircuit)\n        {\n            throw new ArgumentOutOfRangeException(nameof(samplingDuration), $\"Value must be equal to or greater than {resolutionOfCircuit.TotalMilliseconds} milliseconds. This is the minimum resolution of the CircuitBreaker timer.\");\n        }\n\n        if (minimumThroughput <= 1)\n        {\n            throw new ArgumentOutOfRangeException(nameof(minimumThroughput), \"Value must be greater than one.\");\n        }\n\n        if (durationOfBreak < TimeSpan.Zero)","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/App-vNext/Polly/blob/d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac/src/Polly/CircuitBreaker/AdvancedCircuitBreakerSyntax.cs#L210-L246","documentation":"Thrown at policy-construction time by the legacy Polly v7 AdvancedCircuitBreaker when the failureThreshold (a proportion between 0 and 1) is less than or equal to 0. failureThreshold represents the failure ratio that trips the circuit (e.g. 0.5 = 50%); zero or negative means the breaker could never sensibly trigger, so Polly rejects it with ArgumentOutOfRangeException.","triggerScenarios":"Calling PolicyHandle.AdvancedCircuitBreaker(failureThreshold: 0 or negative, ...) or AdvancedCircuitBreakerAsync with the same. Also the typed-result variants. A computed percentage divided by 100 incorrectly (passing 0.5 as 50) or 0 default can trigger it.","commonSituations":"Configuring failureThreshold as a percentage (e.g. 50 for 50%) instead of a fraction (0.5); defaulting an unset threshold to 0; reading a 0 from config when the key was absent.","solutions":["Set failureThreshold to a value strictly greater than 0 and at most 1 (e.g. 0.5 for 50%).","If your config stores a percentage, divide by 100 before passing: configPercent / 100.0.","Validate and fall back to a sane default (e.g. 0.5) when the configured value is non-positive."],"exampleFix":"// before\n.AdvancedCircuitBreaker(failureThreshold: 50, samplingDuration: ..., ...);\n// after\n.AdvancedCircuitBreaker(failureThreshold: 0.5, samplingDuration: ..., ...);","handlingStrategy":"validation","validationCode":"if (!(failureThreshold > 0 && failureThreshold <= 1)) throw new ArgumentOutOfRangeException(nameof(failureThreshold), \"failureThreshold must be in (0, 1].\");\n.AdvancedCircuitBreaker(failureThreshold, samplingDuration, minimumThroughput, durationOfBreak, onBreak, onReset, onHalfOpen);","typeGuard":"static bool IsFailureThresholdValid(double t) => t > 0 && t <= 1;","tryCatchPattern":null,"preventionTips":["Treat failureThreshold as a fraction in (0,1], not a percentage.","If config stores a percentage, divide by 100 before passing.","Default to a sensible value like 0.5 when config is missing or invalid."],"tags":["polly","circuit-breaker","legacy-v7","argument-out-of-range","failure-threshold","configuration"],"backgroundTag":null,"analyzedSha":"d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac","analyzedAt":"2026-08-13T16:36:01.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}