{"record":{"id":"ed0696f8399126af","repo":"dotnet/orleans","slug":"createconnection","errorCode":null,"errorMessage":"createConnection","messagePattern":"createConnection","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubStreamOptions.cs","lineNumber":148,"sourceCode":"        /// </summary>\n        public void ConfigureEventHubConnection(EventHubConnection connection, string consumerGroup)\n        {\n            EventHubName = connection.EventHubName;\n            ConsumerGroup = consumerGroup;\n            ValidateValues(connection.EventHubName, consumerGroup);\n            if (connection is null) throw new ArgumentNullException(nameof(connection));\n            CreateConnection = _ => connection;\n        }\n\n        /// <summary>\n        /// Configures the Azure Event Hub connection using the provided delegate.\n        /// </summary>\n        public void ConfigureEventHubConnection(CreateConnectionDelegate createConnection, string eventHubName, string consumerGroup)\n        {\n            EventHubName = eventHubName;\n            ConsumerGroup = consumerGroup;\n            ValidateValues(eventHubName, consumerGroup);\n            CreateConnection = createConnection ?? throw new ArgumentNullException(nameof(createConnection));\n        }\n\n        private static void ValidateValues(string eventHubName, string consumerGroup)\n        {\n            if (string.IsNullOrWhiteSpace(eventHubName))\n            {\n                throw new ArgumentException(\"A non-null, non-empty value must be provided.\", nameof(eventHubName));\n            }\n\n            if (string.IsNullOrWhiteSpace(consumerGroup))\n            {\n                throw new ArgumentException(\"A non-null, non-empty value must be provided.\", nameof(consumerGroup));\n            }\n        }\n    }\n\n    public class EventHubOptionsValidator : IConfigurationValidator\n    {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubStreamOptions.cs#L130-L166","documentation":"Thrown by the delegate overload of ConfigureEventHubConnection when the supplied CreateConnectionDelegate is null. The library stores the delegate as the connection factory and cannot operate without one.","triggerScenarios":"Calling ConfigureEventHubConnection(null, eventHubName, consumerGroup), or passing a factory field/property that was never assigned.","commonSituations":"A conditional assignment that leaves the delegate null on a cold path; copy-paste from a sample that omits the factory; refactor that resolves the delegate from a nullable DI service.","solutions":["Provide a non-null CreateConnectionDelegate, e.g. new CreateConnectionDelegate(opts => new EventHubConnection(ns, hub, cred, opts)).","If resolving from DI, fall back to one of the other ConfigureEventHubConnection overloads (connection instance or endpoint+token) rather than passing null.","Guard the call site: if (factory is not null) options.ConfigureEventHubConnection(factory, hub, group);"],"exampleFix":"// before\noptions.ConfigureEventHubConnection(null, eventHubName, consumerGroup);\n\n// after\nvar factory = new CreateConnectionDelegate(\n    opts => new EventHubConnection(fqdn, eventHubName, credential, opts));\noptions.ConfigureEventHubConnection(factory, eventHubName, consumerGroup);","handlingStrategy":"validation","validationCode":"if (createConnection is null) throw new ArgumentNullException(nameof(createConnection));\noptions.ConfigureEventHubConnection(createConnection, eventHubName, consumerGroup);","typeGuard":"static bool IsValidFactory(CreateConnectionDelegate? d) => d is not null;","tryCatchPattern":null,"preventionTips":["Build the CreateConnectionDelegate at the call site rather than resolving a nullable service.","Prefer the instance/endpoint overloads when you cannot guarantee a non-null delegate."],"tags":["eventhubs","configuration","null-argument","azure"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}