{"record":{"id":"ed4305e70d3b8ff8","repo":"dotnet/orleans","slug":"a-non-null-non-empty-value-must-be-provided","errorCode":null,"errorMessage":"A non-null, non-empty value must be provided.","messagePattern":"A non-null, non-empty value must be provided\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubStreamOptions.cs","lineNumber":53,"sourceCode":"\n        /// <summary>\n        /// Creates an Azure Event Hub connection.\n        /// </summary>\n        /// <param name=\"connectionOptions\">The connection options.</param>\n        /// <returns>An Azure Event Hub connection.</returns>\n        public delegate EventHubConnection CreateConnectionDelegate(EventHubConnectionOptions connectionOptions);\n\n        /// <summary>\n        /// Configures the Azure Event Hub connection using the provided connection string.\n        /// </summary>\n        public void ConfigureEventHubConnection(string connectionString, string eventHubName, string consumerGroup)\n        {\n            EventHubName = eventHubName;\n            ConsumerGroup = consumerGroup;\n\n            if (string.IsNullOrWhiteSpace(connectionString))\n            {\n                throw new ArgumentException(\"A non-null, non-empty value must be provided.\", nameof(connectionString));\n            }\n\n            ValidateValues(eventHubName, consumerGroup);\n\n            CreateConnection = connectionOptions => new EventHubConnection(connectionString, EventHubName, 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, 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));","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubStreamOptions.cs#L35-L71","documentation":"EventHubOptions.ConfigureEventHubConnection(connectionString, eventHubName, consumerGroup) throws ArgumentException when connectionString is null, empty, or whitespace because it is used directly to construct an Azure EventHubConnection. Azure.Messaging.EventHubs.EventHubConnection itself would throw if given an empty string, but Orleans validates early with a clear message naming the parameter. The connection string must contain the Event Hub namespace endpoint and key information (e.g., Endpoint=sb://...;SharedAccessKeyName=...;SharedAccessKey=...).","triggerScenarios":"Calling ConfigureEventHubConnection with a connectionString that is null, string.Empty, or whitespace-only. This happens when the connection string is read from configuration (appsettings.json, environment variables, Azure Key Vault) and the key is missing or the value is blank.","commonSituations":"The connection string environment variable or appsettings key is misspelled or missing in the deployment environment; using Azure Managed Identity or TokenCredential but accidentally calling the connection-string overload with an empty string; a CI/CD pipeline that does not inject the connection string secret into the environment; local development with a missing user-secrets entry.","solutions":["Verify the connection string is present and non-empty in the configuration source (appsettings.json, environment variable, or user secrets).","If using Azure Managed Identity instead of a connection string, call the TokenCredential overload: ConfigureEventHubConnection(fullyQualifiedNamespace, eventHubName, consumerGroup, tokenCredential).","Add a startup check or IConfigurationValidator to fail fast with a descriptive message if the connection string is missing.","In local development, use dotnet user-secrets or a local appsettings.Development.json to provide the connection string."],"exampleFix":"// before — connection string is null or empty due to missing config\nvar connectionString = builder.Configuration[\"EventHubConnectionString\"];\noptions.ConfigureEventHubConnection(connectionString, \"myhub\", \"$Default\");\n\n// after — validate before calling, or use a non-empty value\nvar connectionString = builder.Configuration[\"EventHubConnectionString\"]\n    ?? throw new InvalidOperationException(\"EventHubConnectionString is not configured.\");\noptions.ConfigureEventHubConnection(connectionString, \"myhub\", \"$Default\");","handlingStrategy":"validation","validationCode":"// Validate connection string before configuring:\nvar connectionString = config.GetConnectionString(\"EventHub\")\n    ?? builder.Configuration[\"EventHub:ConnectionString\"]\n    ?? throw new InvalidOperationException(\"Event Hub connection string is not configured.\");\n\nif (string.IsNullOrWhiteSpace(connectionString))\n    throw new InvalidOperationException(\"Event Hub connection string is empty.\");\n\noptions.ConfigureEventHubConnection(connectionString, eventHubName, consumerGroup);","typeGuard":"static bool IsValidConnectionString(string? connectionString)\n    => !string.IsNullOrWhiteSpace(connectionString)\n       && connectionString.Contains(\"Endpoint=\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":null,"preventionTips":["Store connection strings in environment variables, user secrets (dev), or Azure Key Vault (prod).","Add a startup IConfigurationValidator to verify the connection string is present.","If using managed identity, use the TokenCredential overload instead of the connection-string overload.","In CI/CD, ensure the connection string secret is injected before the application starts."],"tags":["connection-string","configuration","eventhub","validation","azure"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}