{"record":{"id":"d82d2cd8771c1f8e","repo":"dotnet/orleans","slug":"credential","errorCode":null,"errorMessage":"credential","messagePattern":"credential","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubStreamOptions.cs","lineNumber":78,"sourceCode":"\n        /// <summary>\n        /// Configures the Azure Event Hub connection using the provided fully-qualified namespace string and credential.\n        /// </summary>\n        public void ConfigureEventHubConnection(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, AzureNamedKeyCredential credential)\n        {\n            EventHubName = eventHubName;\n            ConsumerGroup = consumerGroup;\n\n            if (string.IsNullOrWhiteSpace(fullyQualifiedNamespace))\n            {\n                throw new ArgumentException(\"A non-null, non-empty value must be provided.\", nameof(fullyQualifiedNamespace));\n            }\n\n            ValidateValues(eventHubName, consumerGroup);\n\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 fully-qualified namespace string and credential.\n        /// </summary>\n        public void ConfigureEventHubConnection(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, AzureSasCredential credential)\n        {\n            EventHubName = eventHubName;\n            ConsumerGroup = consumerGroup;\n\n            if (string.IsNullOrWhiteSpace(fullyQualifiedNamespace))\n            {\n                throw new ArgumentException(\"A non-null, non-empty value must be provided.\", nameof(fullyQualifiedNamespace));\n            }\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubStreamOptions.cs#L60-L96","documentation":"EventHubOptions.ConfigureEventHubConnection(fullyQualifiedNamespace, eventHubName, consumerGroup, AzureNamedKeyCredential) throws ArgumentNullException when the credential argument is null. The AzureNamedKeyCredential carries the shared access key name and key used to authenticate to Event Hub. Without a valid credential, EventHubConnection cannot authenticate, so Orleans fails fast at configuration time rather than at first connection attempt.","triggerScenarios":"Calling the AzureNamedKeyCredential overload with credential set to null. This happens when the AzureNamedKeyCredential is constructed from configuration (key name and key) and one of the components is missing, resulting in a null credential object being passed.","commonSituations":"The shared access key is missing from configuration and the credential construction was skipped or returned null; a factory method that creates the credential returns null on missing config; a DI registration for AzureNamedKeyCredential is not properly resolved; a migration from connection strings to credentials where the credential creation step was omitted.","solutions":["Construct a valid AzureNamedKeyCredential from your shared access key name and key before calling ConfigureEventHubConnection.","Verify both the key name and key value are present in configuration.","If the credential is resolved from DI, ensure it is registered as a singleton and not returning null."],"exampleFix":"// before — credential is null because key config is missing\nAzureNamedKeyCredential credential = null;\nif (config[\"SharedAccessKeyName\"] != null)\n    credential = new AzureNamedKeyCredential(config[\"SharedAccessKeyName\"], config[\"SharedAccessKey\"]);\noptions.ConfigureEventHubConnection(ns, \"myhub\", \"$Default\", credential);\n\n// after — always construct a valid credential\nvar keyName = config[\"SharedAccessKeyName\"]\n    ?? throw new InvalidOperationException(\"SharedAccessKeyName not configured.\");\nvar key = config[\"SharedAccessKey\"]\n    ?? throw new InvalidOperationException(\"SharedAccessKey not configured.\");\nvar credential = new AzureNamedKeyCredential(keyName, key);\noptions.ConfigureEventHubConnection(ns, \"myhub\", \"$Default\", credential);","handlingStrategy":"validation","validationCode":"// Ensure credential is non-null before configuring:\nvar keyName = config[\"EventHub:SharedAccessKeyName\"]\n    ?? throw new InvalidOperationException(\"SharedAccessKeyName is not configured.\");\nvar key = config[\"EventHub:SharedAccessKey\"]\n    ?? throw new InvalidOperationException(\"SharedAccessKey is not configured.\");\n\nvar credential = new AzureNamedKeyCredential(keyName, key);\noptions.ConfigureEventHubConnection(fullyQualifiedNamespace, eventHubName, consumerGroup, credential);","typeGuard":"static bool IsValidCredential(AzureNamedKeyCredential? credential)\n    => credential is not null;","tryCatchPattern":null,"preventionTips":["Construct AzureNamedKeyCredential from configuration keys that are guaranteed to be present.","Register the credential in DI as a singleton if shared across multiple providers.","Consider migrating to TokenCredential (DefaultAzureCredential) for passwordless auth."],"tags":["credential","configuration","eventhub","validation","named-key-credential","azure","null-argument"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}