{"record":{"id":"2b2ad5227147a514","repo":"App-vNext/Polly","slug":"value-must-be-greater-than-zero","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/AsyncBulkheadSyntax.cs","lineNumber":65,"sourceCode":"    /// <summary>\n    /// Builds a bulkhead isolation <see cref=\"Policy\" />, 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    /// <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 BulkheadAsync(\n        int maxParallelization,\n        int maxQueuingActions,\n        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(\n            maxParallelization,\n            maxQueuingActions,\n            onBulkheadRejectedAsync);\n    }\n}","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/App-vNext/Polly/blob/d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac/src/Polly/Bulkhead/AsyncBulkheadSyntax.cs#L47-L83","documentation":"AsyncBulkheadSyntax.BulkheadAsync throws ArgumentOutOfRangeException(nameof(maxParallelization)) when maxParallelization <= 0. The bulkhead needs at least one parallel execution slot to function; zero or negative capacity would reject every action. This is the legacy v7 Polly API guard.","triggerScenarios":"Calling Policy.BulkheadAsync(maxParallelization: 0, ...) or any negative value. Also when maxParallelization is computed from configuration that yields zero.","commonSituations":"Config bound to an int that defaults to 0 when missing; computing parallelization from a CPU count formula that rounds to zero on constrained hosts; passing an uninitialized int field (default 0).","solutions":["Pass a positive integer for maxParallelization (typically the concurrency you want to allow).","Guard config-derived values: maxParallelization = Math.Max(1, configured).","Validate the config value at startup before constructing the policy."],"exampleFix":"// before\nvar policy = Policy.BulkheadAsync(maxParallelization: 0, maxQueuingActions: 10);\n\n// after\nvar policy = Policy.BulkheadAsync(maxParallelization: 10, maxQueuingActions: 10);","handlingStrategy":"validation","validationCode":"if (maxParallelization <= 0) {\n    throw new ArgumentOutOfRangeException(nameof(maxParallelization), \"Use a positive value.\");\n}\n// then call Policy.BulkheadAsync(maxParallelization, ...)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp config-derived concurrency with Math.Max(1, value).","Validate bound configuration integers at startup.","Treat a default-zero int as a configuration smell for capacity settings."],"tags":["bulkhead","legacy","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"}