App-vNext/Polly · error · ArgumentOutOfRangeException

Value must be greater than zero.

Error message

Value must be greater than zero.

What it means

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.

Source

Thrown at src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerSyntax.cs:231

    /// <exception cref="ArgumentOutOfRangeException">minimumThroughput;Value must be greater than one.</exception>
    /// <exception cref="ArgumentOutOfRangeException">durationOfBreak;Value must be greater than zero.</exception>
    /// <exception cref="ArgumentNullException">Thrown when <paramref name="onBreak"/> is <see langword="null"/>.</exception>
    /// <exception cref="ArgumentNullException">Thrown when <paramref name="onReset"/> is <see langword="null"/>.</exception>
    /// <exception cref="ArgumentNullException">Thrown when <paramref name="onHalfOpen"/> is <see langword="null"/>.</exception>
    public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync(
        this PolicyBuilder policyBuilder,
        double failureThreshold,
        TimeSpan samplingDuration,
        int minimumThroughput,
        TimeSpan durationOfBreak,
        Action<Exception, CircuitState, TimeSpan, Context> onBreak,
        Action<Context> onReset, Action onHalfOpen)
    {
        var resolutionOfCircuit = TimeSpan.FromTicks(AdvancedCircuitController<EmptyStruct>.ResolutionOfCircuitTimer);

        if (failureThreshold <= 0)
        {
            throw new ArgumentOutOfRangeException(nameof(failureThreshold), "Value must be greater than zero.");
        }

        if (failureThreshold > 1)
        {
            throw new ArgumentOutOfRangeException(nameof(failureThreshold), "Value must be less than or equal to one.");
        }

        if (samplingDuration < resolutionOfCircuit)
        {
            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.");
        }

        if (minimumThroughput <= 1)
        {
            throw new ArgumentOutOfRangeException(nameof(minimumThroughput), "Value must be greater than one.");
        }

        if (durationOfBreak < TimeSpan.Zero)

View on GitHub (pinned to d0e46bdb1e)

Solutions

  1. Set failureThreshold to a value in (0,1] such as 0.5.
  2. Validate configured value lies in (0,1] before building the policy.
  3. Guard division when computing the ratio at runtime.

Example fix

// before
.AdvancedCircuitBreakerAsync(
    failureThreshold: 0,
    samplingDuration: TimeSpan.FromSeconds(10),
    minimumThroughput: 10,
    durationOfBreak: TimeSpan.FromSeconds(30),
    onBreak: (_, __, ___, ____) => { },
    onReset: _ => { },
    onHalfOpen: () => { });

// after
.AdvancedCircuitBreakerAsync(
    failureThreshold: 0.5,
    ...);
Defensive patterns

Strategy: validation

Validate before calling

if (failureThreshold <= 0 || failureThreshold > 1)
    throw new ArgumentOutOfRangeException(nameof(failureThreshold), "failureThreshold must be in (0,1].");

Type guard

static bool IsValidFailureThreshold(double t) => t > 0 && t <= 1;

Prevention

When it happens

Trigger: Calling Policy.Handle<...>().CircuitBreakerAsync(...).AdvancedCircuitBreakerAsync(failureThreshold: 0, ...) (via the async advanced syntax). The check is `failureThreshold <= 0`.

Common situations: Default/missing config value of 0, or a computed ratio that resolves to 0 due to a zero denominator.

Related errors


AI-assisted analysis of App-vNext/Polly@d0e46bdb1e (2026-08-13). Data as JSON: /api/errors/5ff0c83fc73c8f90. Report an issue: GitHub.