{"record":{"id":"aeb2eea3065b83eb","repo":"dotnetcore/CAP","slug":"value-cannot-be-null-parameter-configure","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'configure')","messagePattern":"Value cannot be null\\. \\(Parameter 'configure'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/DotNetCore.CAP.AmazonSQS/CAP.Options.Extensions.cs","lineNumber":20,"sourceCode":"// Licensed under the MIT License. See License.txt in the project root for license information.\n\nusing System;\nusing Amazon;\nusing DotNetCore.CAP;\n\n// ReSharper disable once CheckNamespace\nnamespace Microsoft.Extensions.DependencyInjection;\n\npublic static class CapOptionsExtensions\n{\n    public static CapOptions UseAmazonSQS(this CapOptions options, RegionEndpoint region)\n    {\n        return options.UseAmazonSQS(opt => { opt.Region = region; });\n    }\n\n    public static CapOptions UseAmazonSQS(this CapOptions options, Action<AmazonSQSOptions> configure)\n    {\n        if (configure == null) throw new ArgumentNullException(nameof(configure));\n\n        options.RegisterExtension(new AmazonSQSOptionsExtension(configure));\n\n        return options;\n    }\n}","sourceCodeStart":2,"sourceCodeEnd":26,"githubUrl":"https://github.com/dotnetcore/CAP/blob/e52b8508e54cdb7a9ce7f9fec03d9ea8ad2710fb/src/DotNetCore.CAP.AmazonSQS/CAP.Options.Extensions.cs#L2-L26","documentation":"The UseAmazonSQS extension method registers an AmazonSQSOptionsExtension whose delegate configures the SQS options. Passing a null configure delegate would make the extension unusable, so the method throws ArgumentNullException immediately.","triggerScenarios":"Calling options.UseAmazonSQS(null) — e.g. the configure lambda is built dynamically or stored in a variable that is null, or using the overload with a region string and then chaining a null delegate.","commonSituations":"Configuration-driven CAP setup where the AWS options section is bound to an Action<AmazonSQSOptions> that is never assigned; refactoring that renamed a local method group leaving the delegate null.","solutions":["Pass a configuration lambda, even an empty one: options.UseAmazonSQS(opt => { ... })","Use the convenience overload options.UseAmazonSQS(\"region\") if only the region is needed","Check that any variable holding the delegate is assigned before calling","Wrap registration in try/catch and log the null delegate at startup"],"exampleFix":"// before\nAction<AmazonSQSOptions>? configure = LoadConfigure(); // null\noptions.UseAmazonSQS(configure!);\n// after\noptions.UseAmazonSQS(opt => { opt.Region = \"us-east-1\"; });","handlingStrategy":"validation","validationCode":"if (configure is null) throw new InvalidOperationException(\"UseAmazonSQS requires a configure delegate\");","typeGuard":"bool HasConfigure(Action<AmazonSQSOptions>? a) => a is not null;","tryCatchPattern":"try { options.UseAmazonSQS(configure); } catch (ArgumentNullException ex) when (ex.ParamName == \"configure\") { logger.LogError(ex, \"SQS configure delegate was null\"); throw; }","preventionTips":["Pass an explicit lambda inline rather than a delegate variable","Prefer the convenience region overload when no advanced options are needed"],"tags":["dotnet","null-argument","sqs","configuration-extension"],"backgroundTag":"null-argument","analyzedSha":"e52b8508e54cdb7a9ce7f9fec03d9ea8ad2710fb","analyzedAt":"2026-09-14T14:46:34.677Z","contentChangedAt":"2026-09-14T14:46:34.677Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}