{"record":{"id":"9a4d198c70ee9e79","repo":"App-vNext/Polly","slug":"value-cannot-be-null-9a4d19","errorCode":null,"errorMessage":"Value cannot be null.","messagePattern":"Value cannot be null\\.","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Polly/Bulkhead/BulkheadTResultSyntax.cs","lineNumber":69,"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=\"onBulkheadRejected\"/> is <see langword=\"null\"/>.</exception>\n    public static BulkheadPolicy<TResult> Bulkhead<TResult>(int maxParallelization, int maxQueuingActions, Action<Context> onBulkheadRejected)\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 (onBulkheadRejected == null)\n        {\n            throw new ArgumentNullException(nameof(onBulkheadRejected));\n        }\n\n        return new BulkheadPolicy<TResult>(\n            maxParallelization,\n            maxQueuingActions,\n            onBulkheadRejected);\n    }\n}\n","sourceCodeStart":51,"sourceCodeEnd":78,"githubUrl":"https://github.com/App-vNext/Polly/blob/d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac/src/Polly/Bulkhead/BulkheadTResultSyntax.cs#L51-L78","documentation":"Thrown as ArgumentNullException(nameof(onBulkheadRejected)) from the generic Policy.Bulkhead<TResult>(maxParallelization, maxQueuingActions, onBulkheadRejected) overload when the rejection callback is null. The guard at BulkheadTResultSyntax.cs:69–72 fires at construction time.","triggerScenarios":"Calling Policy.Bulkhead<TResult>(maxParallelization, maxQueuingActions, null) — passing null as the onBulkheadRejected Action<Context>. The guard fires before the BulkheadPolicy<TResult> is constructed.","commonSituations":"Using the three-parameter generic overload when the two-parameter overload would suffice. Passing a callback variable that was conditionally set and ended up null. Migrating from a non-generic overload and forgetting to carry the callback.","solutions":["Use the two-parameter Policy.Bulkhead<TResult>(maxParallelization, maxQueuingActions) overload if no rejection callback is needed","Pass a no-op lambda _ => { } when a callback is not required but the three-parameter overload is used","Ensure the callback variable is non-null"],"exampleFix":"// before\nvar policy = Policy.Bulkhead<string>(10, 5, null); // throws\n\n// after\nvar policy = Policy.Bulkhead<string>(10, 5); // two-parameter overload\n// or:\nvar policy = Policy.Bulkhead<string>(10, 5, _ => { });","handlingStrategy":"validation","validationCode":"Action<Context> safeOnReject = onBulkheadRejected ?? (_ => { });\nvar policy = Policy.Bulkhead<TResult>(maxParallelization, maxQueuingActions, safeOnReject);","typeGuard":"public static bool IsNonNullCallback(Action<Context> callback) => callback is not null;","tryCatchPattern":null,"preventionTips":["Use the two-parameter Policy.Bulkhead<TResult>(maxParallelization, maxQueuingActions) overload when no callback is needed","Coalesce null callbacks with a no-op lambda","Prefer the simpler overload unless rejection callbacks are explicitly required"],"tags":["bulkhead","null-argument","configuration","callback","generic","construction"],"backgroundTag":null,"analyzedSha":"d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac","analyzedAt":"2026-08-13T16:36:01.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}