{"record":{"id":"f43f072ca5131245","repo":"App-vNext/Polly","slug":"maxburst-must-be-an-integer-greater-than-or-equal-f43f07","errorCode":null,"errorMessage":"maxBurst must be an integer greater than or equal to 1.","messagePattern":"maxBurst must be an integer greater than or equal to 1\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Polly/RateLimit/AsyncRateLimitTResultSyntax.cs","lineNumber":78,"sourceCode":"    public static AsyncRateLimitPolicy<TResult> RateLimitAsync<TResult>(\n        int numberOfExecutions,\n        TimeSpan perTimeSpan,\n        int maxBurst,\n        Func<TimeSpan, Context, TResult>? retryAfterFactory)\n    {\n        if (numberOfExecutions < 1)\n        {\n            throw new ArgumentOutOfRangeException(nameof(numberOfExecutions), numberOfExecutions, $\"{nameof(numberOfExecutions)} per timespan must be an integer greater than or equal to 1.\");\n        }\n\n        if (perTimeSpan <= TimeSpan.Zero)\n        {\n            throw new ArgumentOutOfRangeException(nameof(perTimeSpan), perTimeSpan, $\"{nameof(perTimeSpan)} must be a positive timespan.\");\n        }\n\n        if (maxBurst < 1)\n        {\n            throw new ArgumentOutOfRangeException(nameof(maxBurst), maxBurst, $\"{nameof(maxBurst)} must be an integer greater than or equal to 1.\");\n        }\n\n        var onePer = TimeSpan.FromTicks(perTimeSpan.Ticks / numberOfExecutions);\n\n        if (onePer <= TimeSpan.Zero)\n        {\n            throw new ArgumentOutOfRangeException(nameof(perTimeSpan), perTimeSpan, \"The number of executions per timespan must be positive.\");\n        }\n\n        IRateLimiter rateLimiter = new LockFreeTokenBucketRateLimiter(onePer, maxBurst);\n\n        return new AsyncRateLimitPolicy<TResult>(rateLimiter, retryAfterFactory);\n    }\n}\n","sourceCodeStart":60,"sourceCodeEnd":93,"githubUrl":"https://github.com/App-vNext/Polly/blob/d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac/src/Polly/RateLimit/AsyncRateLimitTResultSyntax.cs#L60-L93","documentation":"Thrown by the typed RateLimitAsync<TResult> overload when maxBurst is less than 1. maxBurst is the token-bucket capacity; a non-positive capacity makes the limiter perpetually reject. Same guard as the factory-less overload.","triggerScenarios":"Calling Policy.RateLimitAsync<TResult>(n, ts, 0, factory) or with a negative maxBurst. The retryAfterFactory is irrelevant to this check.","commonSituations":"maxBurst from an optional config key defaulting to 0; mis-copy of a config template omitting the value; intent to suppress bursts implemented as 0 instead of maxBurst = numberOfExecutions.","solutions":["Set maxBurst to a positive integer (>= numberOfExecutions for no burst suppression).","Clamp config: Math.Max(1, parsed).","Use maxBurst = numberOfExecutions when you want to disallow bursts rather than 0.","Validate the full config triple at startup."],"exampleFix":"// before\nvar p = Policy.RateLimitAsync<int>(10, TimeSpan.FromSeconds(1), 0, null);\n\n// after\nvar p = Policy.RateLimitAsync<int>(10, TimeSpan.FromSeconds(1), 10, null);","handlingStrategy":"validation","validationCode":"int burst = Math.Max(1, parsedMaxBurst);\nvar p = Policy.RateLimitAsync<TResult>(n, perTimeSpan, burst, retryAfterFactory);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use maxBurst = numberOfExecutions to suppress bursts rather than 0.","Clamp config: Math.Max(1, parsed).","Validate the triple at startup."],"tags":["argumentoutofrange","ratelimit","config","validation","tresult","legacy-api"],"backgroundTag":null,"analyzedSha":"d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac","analyzedAt":"2026-08-13T16:36:01.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}