App-vNext/Polly · error · ArgumentOutOfRangeException

Value must be less than or equal to one.

Error message

Value must be less than or equal to one.

What it means

Thrown at policy-construction time by the legacy Polly v7 AdvancedCircuitBreaker when failureThreshold exceeds 1. failureThreshold is a proportion (max 1.0 = 100%); values above 1 are not a valid ratio and would make the breaker logically impossible to trip, so Polly rejects them with ArgumentOutOfRangeException.

Source

Thrown at src/Polly/CircuitBreaker/AdvancedCircuitBreakerSyntax.cs:233

        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)
        {
            throw new ArgumentOutOfRangeException(nameof(durationOfBreak), "Value must be greater than zero.");
        }

        if (onBreak == null)

View on GitHub (pinned to d0e46bdb1e)

Solutions

  1. Pass failureThreshold as a fraction between 0 (exclusive) and 1 (inclusive).
  2. If config is a percentage, convert: configPercent / 100.0 before calling.
  3. Clamp to a maximum of 1.0 when reading from an external source.

Example fix

// before
.AdvancedCircuitBreaker(failureThreshold: 100, samplingDuration: ..., ...);
// after
.AdvancedCircuitBreaker(failureThreshold: 1.0, samplingDuration: ..., ...); // 100%
Defensive patterns

Strategy: validation

Validate before calling

if (failureThreshold > 1) throw new ArgumentOutOfRangeException(nameof(failureThreshold), "failureThreshold must be <= 1 (use a fraction, not a percentage).");
.AdvancedCircuitBreaker(failureThreshold, samplingDuration, minimumThroughput, durationOfBreak, onBreak, onReset, onHalfOpen);

Type guard

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

Prevention

When it happens

Trigger: Calling AdvancedCircuitBreaker/Async with failureThreshold greater than 1.0 — typically passing a percentage (50, 100) instead of a fraction (0.5, 1.0).

Common situations: Storing/entering the threshold as a whole-number percentage and forgetting to divide by 100; config returning 100 meaning '100%' but passed directly.

Related errors


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