{"record":{"id":"346b8cef971b4bff","repo":"App-vNext/Polly","slug":"value-must-be-greater-than-zero-346b8c","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/Bulkhead/AsyncBulkheadTResultSyntax.cs","lineNumber":58,"sourceCode":"        => BulkheadAsync<TResult>(maxParallelization, maxQueuingActions, EmptyHandler);\n\n    /// <summary>\n    /// Builds a bulkhead isolation <see cref=\"AsyncPolicy{TResult}\" />, which limits the maximum concurrency of actions executed through the policy.  Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.\n    /// <para>When an execution would cause the number of actions executing concurrently through the policy to exceed <paramref name=\"maxParallelization\" />, the policy allows a further <paramref name=\"maxQueuingActions\" /> executions to queue, waiting for a concurrent execution slot.  When an execution would cause the number of queuing actions to exceed <paramref name=\"maxQueuingActions\" />, a <see cref=\"BulkheadRejectedException\" /> is thrown.</para>\n    /// </summary>\n    /// <typeparam name=\"TResult\">The type of the result.</typeparam>\n    /// <param name=\"maxParallelization\">The maximum number of concurrent actions that may be executing through the policy.</param>\n    /// <param name=\"maxQueuingActions\">The maximum number of actions that may be queuing, waiting for an execution slot.</param>\n    /// <param name=\"onBulkheadRejectedAsync\">An action to call asynchronously, if the bulkhead rejects execution due to oversubscription.</param>\n    /// <returns>The policy instance.</returns>\n    /// <exception cref=\"ArgumentOutOfRangeException\">maxParallelization;Value must be greater than zero.</exception>\n    /// <exception cref=\"ArgumentOutOfRangeException\">maxQueuingActions;Value must be greater than or equal to zero.</exception>\n    /// <exception cref=\"ArgumentNullException\">Thrown when <paramref name=\"onBulkheadRejectedAsync\"/> is <see langword=\"null\"/>.</exception>\n    public static AsyncBulkheadPolicy<TResult> BulkheadAsync<TResult>(int maxParallelization, int maxQueuingActions, Func<Context, Task> onBulkheadRejectedAsync)\n    {\n        if (maxParallelization <= 0)\n        {\n            throw new ArgumentOutOfRangeException(nameof(maxParallelization), \"Value must be greater than zero.\");\n        }\n\n        if (maxQueuingActions < 0)\n        {\n            throw new ArgumentOutOfRangeException(nameof(maxQueuingActions), \"Value must be greater than or equal to zero.\");\n        }\n\n        if (onBulkheadRejectedAsync == null)\n        {\n            throw new ArgumentNullException(nameof(onBulkheadRejectedAsync));\n        }\n\n        return new AsyncBulkheadPolicy<TResult>(\n            maxParallelization,\n            maxQueuingActions,\n            onBulkheadRejectedAsync);\n    }\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/App-vNext/Polly/blob/d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac/src/Polly/Bulkhead/AsyncBulkheadTResultSyntax.cs#L40-L76","documentation":"AsyncBulkheadTResultSyntax.BulkheadAsync<TResult> throws ArgumentOutOfRangeException(nameof(maxParallelization)) when maxParallelization <= 0. This is the generic legacy v7 bulkhead policy; like the non-generic overload it requires at least one parallel slot.","triggerScenarios":"Calling Policy<T>.BulkheadAsync(maxParallelization: 0, ...) or any non-positive value when constructing a result-typed bulkhead.","commonSituations":"Config bound to a default-zero int; formula-derived concurrency that underflows to zero; uninitialized field.","solutions":["Pass a positive maxParallelization.","Clamp derived values with Math.Max(1, value).","Validate config at startup."],"exampleFix":"// before\nvar policy = Policy<string>.BulkheadAsync(maxParallelization: 0, maxQueuingActions: 5);\n\n// after\nvar policy = Policy<string>.BulkheadAsync(maxParallelization: 5, maxQueuingActions: 5);","handlingStrategy":"validation","validationCode":"if (maxParallelization <= 0) {\n    throw new ArgumentOutOfRangeException(nameof(maxParallelization), \"Use a positive value.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp config-derived concurrency with Math.Max(1, value).","Validate bound configuration integers at startup.","Watch for default-zero ints feeding capacity arguments."],"tags":["bulkhead","legacy","generic","argument-out-of-range","validation","polly-v7"],"backgroundTag":null,"analyzedSha":"d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac","analyzedAt":"2026-08-13T16:36:01.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}