{"record":{"id":"faf533716c7164e7","repo":"App-vNext/Polly","slug":"value-cannot-be-null-faf533","errorCode":null,"errorMessage":"Value cannot be null.","messagePattern":"Value cannot be null\\.","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Polly/Bulkhead/AsyncBulkheadTResultSyntax.cs","lineNumber":68,"sourceCode":"    /// <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\n    private static Task EmptyHandler(Context context) => TaskHelper.EmptyTask;\n}\n","sourceCodeStart":50,"sourceCodeEnd":79,"githubUrl":"https://github.com/App-vNext/Polly/blob/d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac/src/Polly/Bulkhead/AsyncBulkheadTResultSyntax.cs#L50-L79","documentation":"AsyncBulkheadTResultSyntax.BulkheadAsync<TResult> throws ArgumentNullException(nameof(onBulkheadRejectedAsync)) when the rejection callback is null. Same rationale as the non-generic overload: the callback runs on rejection, so a null one is rejected at construction rather than failing later.","triggerScenarios":"Calling Policy<T>.BulkheadAsync(maxParallelization, maxQueuingActions, null).","commonSituations":"Reaching for the 3-argument overload without wanting a custom handler; passing an unassigned field; refactoring that removed the callback.","solutions":["Use the 2-argument overload Policy<T>.BulkheadAsync(maxParallelization, maxQueuingActions) to get the default handler.","If using the 3-argument overload, pass a non-null Func<Context, Task>."],"exampleFix":"// before\nvar policy = Policy<string>.BulkheadAsync(5, 10, null);\n\n// after\nvar policy = Policy<string>.BulkheadAsync(5, 10); // default handler","handlingStrategy":"validation","validationCode":"if (onBulkheadRejectedAsync == null) {\n    // prefer the 2-arg overload; otherwise supply a no-op:\n    onBulkheadRejectedAsync = _ => Task.CompletedTask;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the 2-argument Policy<T>.BulkheadAsync overload unless you need a custom handler.","When using the 3-argument overload, always pass a non-null callback.","Static-analyze for null literals in callback positions."],"tags":["bulkhead","legacy","generic","argument-null","validation","polly-v7"],"backgroundTag":null,"analyzedSha":"d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac","analyzedAt":"2026-08-13T16:36:01.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}