{"record":{"id":"46ec987a4c3b8054","repo":"dotnet/orleans","slug":"connection","errorCode":null,"errorMessage":"connection","messagePattern":"connection","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubStreamOptions.cs","lineNumber":136,"sourceCode":"\n            ValidateValues(eventHubName, consumerGroup);\n            if (credential is null)\n            {\n                throw new ArgumentNullException(nameof(credential));\n            }\n            \n            CreateConnection = connectionOptions => new EventHubConnection(fullyQualifiedNamespace, EventHubName, credential, connectionOptions);\n        }\n\n        /// <summary>\n        /// Configures the Azure Event Hub connection using the provided connection instance.\n        /// </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            {","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubStreamOptions.cs#L118-L154","documentation":"Thrown by EventHubOptions.ConfigureEventHubConnection(EventHubConnection, string) when the caller passes a null EventHubConnection instance. The library requires a live, already-constructed EventHubConnection to bind as the singleton connection factory. Note the null check executes after connection.EventHubName is dereferenced, so in practice a null argument will throw NullReferenceException on the prior line before reaching this guard.","triggerScenarios":"Calling ConfigureEventHubConnection(null, consumerGroup) where the first argument is a null EventHubConnection reference.","commonSituations":"A DI container returns null for EventHubConnection because the registration is missing or fails; passing a not-yet-initialized field; refactoring that drops the assignment before the call.","solutions":["Ensure the EventHubConnection instance is constructed (e.g. new EventHubConnection(fullyQualifiedNamespace, eventHubName, credential)) before calling ConfigureEventHubConnection.","Register EventHubConnection in your DI container and resolve it before passing it in.","If you cannot build the instance eagerly, use the delegate overload ConfigureEventHubConnection(CreateConnectionDelegate, string, string) instead."],"exampleFix":"// before\noptions.ConfigureEventHubConnection(existingConnection, consumerGroup); // existingConnection is null\n\n// after\nvar connection = new EventHubConnection(fullyQualifiedNamespace, eventHubName, credential);\noptions.ConfigureEventHubConnection(connection, consumerGroup);","handlingStrategy":"validation","validationCode":"if (connection is null) throw new ArgumentNullException(nameof(connection));\noptions.ConfigureEventHubConnection(connection, consumerGroup);","typeGuard":"static bool IsValidConnection(EventHubConnection? c) => c is not null;","tryCatchPattern":null,"preventionTips":["Construct EventHubConnection before the call, never pass unresolved nullable fields.","Register EventHubConnection as a singleton in DI and resolve it explicitly."],"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"}