{"record":{"id":"0118e01f7cff0b01","repo":"App-vNext/Polly","slug":"value-must-be-greater-than-zero-0118e0","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/AsyncAdvancedCircuitBreakerTResultSyntax.cs","lineNumber":221,"sourceCode":"    /// <param name=\"onReset\">The action to call when the circuit resets to a <see cref=\"CircuitState.Closed\"/> state.</param>\n    /// <param name=\"onHalfOpen\">The action to call when the circuit transitions to <see cref=\"CircuitState.HalfOpen\"/> state, ready to try action executions again. </param>\n    /// <returns>The policy instance.</returns>\n    /// <remarks>(see \"Release It!\" by Michael T. Nygard fi).</remarks>\n    /// <exception cref=\"ArgumentOutOfRangeException\">failureThreshold;Value must be greater than zero.</exception>\n    /// <exception cref=\"ArgumentOutOfRangeException\">failureThreshold;Value must be less than or equal to one.</exception>\n    /// <exception cref=\"ArgumentOutOfRangeException\">samplingDuration;Value must be equal to or greater than the minimum resolution of the CircuitBreaker timer.</exception>\n    /// <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<TResult> AdvancedCircuitBreakerAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, double failureThreshold, TimeSpan samplingDuration, int minimumThroughput, TimeSpan durationOfBreak, Action<DelegateResult<TResult>, CircuitState, TimeSpan, Context> onBreak, 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":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/App-vNext/Polly/blob/d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs#L203-L239","documentation":"Thrown by the legacy v7 async AdvancedCircuitBreakerAsync<T> (generic TResult) syntax when failureThreshold is zero or negative. failureThreshold is the failure ratio (0,1] for opening the circuit. Fires at policy construction time.","triggerScenarios":"Calling Policy.HandleResult<T>(...).AdvancedCircuitBreakerAsync(failureThreshold: 0, ...). The check is `failureThreshold <= 0`.","commonSituations":"Missing config defaulting to 0, or a dynamically computed ratio that yields 0.","solutions":["Set failureThreshold to a ratio in (0,1] (e.g. 0.5).","Validate the configured value is in (0,1] at startup.","Guard against zero denominators when computing the ratio."],"exampleFix":"// before\nPolicy.HandleResult<HttpResponseMessage>(r => !r.IsSuccessStatusCode)\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\nPolicy.HandleResult<HttpResponseMessage>(r => !r.IsSuccessStatusCode)\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":["Share a single options validator across all AdvancedCircuitBreaker overloads.","Guard against zero denominators when computing the ratio at runtime.","Treat the value as a ratio, not a percent."],"tags":["circuit-breaker","argument-validation","legacy-api","async","generic-result","configuration"],"backgroundTag":null,"analyzedSha":"d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac","analyzedAt":"2026-08-13T16:36:01.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}