{"record":{"id":"5ff0c83fc73c8f90","repo":"App-vNext/Polly","slug":"value-must-be-greater-than-zero-5ff0c8","errorCode":null,"errorMessage":"Value must be greater than zero.","messagePattern":"Value must be greater than zero\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerSyntax.cs","lineNumber":231,"sourceCode":"    /// <exception cref=\"ArgumentOutOfRangeException\">minimumThroughput;Value must be greater than one.</exception>\n    /// <exception cref=\"ArgumentOutOfRangeException\">durationOfBreak;Value must be greater than zero.</exception>\n    /// <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    public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync(\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, 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":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/App-vNext/Polly/blob/d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerSyntax.cs#L213-L249","documentation":"Thrown by the legacy v7 async AdvancedCircuitBreaker syntax (non-generic) when failureThreshold is zero or negative. failureThreshold is the failure ratio (0,1] that opens the advanced circuit. Fires at policy construction, not execution.","triggerScenarios":"Calling Policy.Handle<...>().CircuitBreakerAsync(...).AdvancedCircuitBreakerAsync(failureThreshold: 0, ...) (via the async advanced syntax). The check is `failureThreshold <= 0`.","commonSituations":"Default/missing config value of 0, or a computed ratio that resolves to 0 due to a zero denominator.","solutions":["Set failureThreshold to a value in (0,1] such as 0.5.","Validate configured value lies in (0,1] before building the policy.","Guard division when computing the ratio at runtime."],"exampleFix":"// before\n.AdvancedCircuitBreakerAsync(\n    failureThreshold: 0,\n    samplingDuration: TimeSpan.FromSeconds(10),\n    minimumThroughput: 10,\n    durationOfBreak: TimeSpan.FromSeconds(30),\n    onBreak: (_, __, ___, ____) => { },\n    onReset: _ => { },\n    onHalfOpen: () => { });\n\n// after\n.AdvancedCircuitBreakerAsync(\n    failureThreshold: 0.5,\n    ...);","handlingStrategy":"validation","validationCode":"if (failureThreshold <= 0 || failureThreshold > 1)\n    throw new ArgumentOutOfRangeException(nameof(failureThreshold), \"failureThreshold must be in (0,1].\");","typeGuard":"static bool IsValidFailureThreshold(double t) => t > 0 && t <= 1;","tryCatchPattern":null,"preventionTips":["Reuse the same factory/validation for sync and async breaker construction.","Validate options once at startup, not per call.","Guard against zero denominators when computing the ratio dynamically."],"tags":["circuit-breaker","argument-validation","legacy-api","async","configuration"],"backgroundTag":null,"analyzedSha":"d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac","analyzedAt":"2026-08-13T16:36:01.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}