{"record":{"id":"ba51e5e7a988212e","repo":"App-vNext/Polly","slug":"value-must-be-equal-to-or-greater-than-resolution","errorCode":null,"errorMessage":"Value must be equal to or greater than {resolutionOfCircuit.TotalMilliseconds} milliseconds. This is the minimum resolution of the CircuitBreaker timer.","messagePattern":"Value must be equal to or greater than (.+?) milliseconds\\. This is the minimum resolution of the CircuitBreaker timer\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Polly/CircuitBreaker/AdvancedCircuitBreakerSyntax.cs","lineNumber":238,"sourceCode":"        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)\n        {\n            throw new ArgumentOutOfRangeException(nameof(durationOfBreak), \"Value must be greater than zero.\");\n        }\n\n        if (onBreak == null)\n        {\n            throw new ArgumentNullException(nameof(onBreak));\n        }\n\n        if (onReset == null)","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/App-vNext/Polly/blob/d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac/src/Polly/CircuitBreaker/AdvancedCircuitBreakerSyntax.cs#L220-L256","documentation":"Thrown at policy-construction time by the legacy Polly v7 AdvancedCircuitBreaker when samplingDuration is smaller than the circuit breaker's internal timer resolution. The advanced breaker samples failures over fixed timeslices; the resolution is ResolutionOfCircuitTimer = 20ms, so samplingDuration must be at least 20 milliseconds. Below that, the sampling windows cannot be computed, hence ArgumentOutOfRangeException.","triggerScenarios":"Calling AdvancedCircuitBreaker/Async with samplingDuration less than 20ms (e.g. TimeSpan.Zero, TimeSpan.FromMilliseconds(1), or a negative/very small value).","commonSituations":"samplingDuration sourced from config that defaulted to 0 when the key was missing; a unit-conversion mistake (passing seconds where milliseconds were intended, or vice-versa, yielding a tiny value); passing TimeSpan.Zero by accident.","solutions":["Set samplingDuration to at least 20ms; a practically useful value is in the hundreds of milliseconds to seconds range (e.g. TimeSpan.FromSeconds(10)).","Validate configured samplingDuration against TimeSpan.FromMilliseconds(20) and fall back to a sane default.","Check the unit of any value read from config (seconds vs milliseconds) before constructing the TimeSpan."],"exampleFix":"// before\n.AdvancedCircuitBreaker(0.5, TimeSpan.Zero, 10, TimeSpan.FromSeconds(30), ...);\n// after\n.AdvancedCircuitBreaker(0.5, TimeSpan.FromSeconds(10), 10, TimeSpan.FromSeconds(30), ...);","handlingStrategy":"validation","validationCode":"var minResolution = TimeSpan.FromMilliseconds(20);\nif (samplingDuration < minResolution) throw new ArgumentOutOfRangeException(nameof(samplingDuration), $\"Must be >= {minResolution.TotalMilliseconds}ms.\");\n.AdvancedCircuitBreaker(failureThreshold, samplingDuration, minimumThroughput, durationOfBreak, onBreak, onReset, onHalfOpen);","typeGuard":"static bool IsSamplingDurationValid(TimeSpan d) => d >= TimeSpan.FromMilliseconds(20);","tryCatchPattern":null,"preventionTips":["Use a samplingDuration in the seconds range (e.g. 10s) for meaningful failure ratios.","Verify the unit (seconds vs milliseconds) of any config value before building the TimeSpan.","Default to a sane value when config is missing instead of 0."],"tags":["polly","circuit-breaker","legacy-v7","argument-out-of-range","sampling-duration","configuration"],"backgroundTag":null,"analyzedSha":"d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac","analyzedAt":"2026-08-13T16:36:01.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}