{"record":{"id":"580949befdb75e69","repo":"App-vNext/Polly","slug":"value-cannot-be-null","errorCode":null,"errorMessage":"Value cannot be null.","messagePattern":"Value cannot be null\\.","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Polly/Bulkhead/AsyncBulkheadSyntax.cs","lineNumber":75,"sourceCode":"    /// <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}\n","sourceCodeStart":57,"sourceCodeEnd":84,"githubUrl":"https://github.com/App-vNext/Polly/blob/d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac/src/Polly/Bulkhead/AsyncBulkheadSyntax.cs#L57-L84","documentation":"AsyncBulkheadSyntax.BulkheadAsync throws ArgumentNullException(nameof(onBulkheadRejectedAsync)) when the rejection callback is null. The bulkhead invokes this callback when an action is rejected due to all slots and queue being full, so a null handler would NRE at rejection time; the constructor rejects it eagerly.","triggerScenarios":"Calling the 3-argument Policy.BulkheadAsync(maxParallelization, maxQueuingActions, null) overload with a null callback.","commonSituations":"Using the explicit-callback overload by mistake when you do not need a custom handler; passing a field that was never assigned; refactoring that dropped the callback argument.","solutions":["Use the 2-argument overload Policy.BulkheadAsync(maxParallelization, maxQueuingActions) which supplies a default no-op handler.","If using the 3-argument overload, pass a non-null Func<Context, Task> (e.g. _ => Task.CompletedTask)."],"exampleFix":"// before\nvar policy = Policy.BulkheadAsync(5, 10, null);\n\n// after\nvar policy = Policy.BulkheadAsync(5, 10); // uses default handler","handlingStrategy":"validation","validationCode":"if (onBulkheadRejectedAsync == null) {\n    // use the 2-arg overload instead, or supply a no-op:\n    onBulkheadRejectedAsync = _ => Task.CompletedTask;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer the 2-argument BulkheadAsync overload when you do not need a custom rejection callback.","If using the 3-argument overload, always pass a non-null Func<Context, Task>.","Static-analyze for null literals passed to callback parameters."],"tags":["bulkhead","legacy","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"}