{"record":{"id":"8e931d0b6353b05c","repo":"dotnet/orleans","slug":"settings","errorCode":null,"errorMessage":"settings","messagePattern":"settings","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubAdapterReceiver.cs","lineNumber":101,"sourceCode":"                (partition, _) => checkpointerFactory(partition),\n                loggerFactory,\n                monitor,\n                loadSheddingOptions,\n                environmentStatisticsProvider,\n                eventHubReceiverFactory)\n        {\n        }\n\n        public EventHubAdapterReceiver(EventHubPartitionSettings settings,\n            Func<string, IStreamQueueCheckpointer<string>, ILoggerFactory, IEventHubQueueCache> cacheFactory,\n            Func<string, CancellationToken, Task<IStreamQueueCheckpointer<string>>> checkpointerFactory,\n            ILoggerFactory loggerFactory,\n            IQueueAdapterReceiverMonitor monitor,\n            LoadSheddingOptions loadSheddingOptions,\n            IEnvironmentStatisticsProvider environmentStatisticsProvider,\n            Func<EventHubPartitionSettings, string, ILogger, IEventHubReceiver>? eventHubReceiverFactory = null)\n        {\n            this.settings = settings ?? throw new ArgumentNullException(nameof(settings));\n            this.cacheFactory = cacheFactory ?? throw new ArgumentNullException(nameof(cacheFactory));\n            this.checkpointerFactory = checkpointerFactory ?? throw new ArgumentNullException(nameof(checkpointerFactory));\n            this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));\n            this.logger = this.loggerFactory.CreateLogger<EventHubAdapterReceiver>();\n            this.monitor = monitor ?? throw new ArgumentNullException(nameof(monitor));\n            this.loadSheddingOptions = loadSheddingOptions ?? throw new ArgumentNullException(nameof(loadSheddingOptions));\n            this.environmentStatisticsProvider = environmentStatisticsProvider;\n            this.eventHubReceiverFactory = eventHubReceiverFactory == null ? EventHubAdapterReceiver.CreateReceiver : eventHubReceiverFactory;\n        }\n\n        public async Task Initialize(TimeSpan timeout)\n        {\n            LogInfoInitializingEventHubPartition(this.settings.Hub.EventHubName, this.settings.Partition);\n\n            // if receiver was already running, do nothing\n            if (ReceiverRunning == Interlocked.Exchange(ref this.receiverState, ReceiverRunning))\n            {\n                return;","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubAdapterReceiver.cs#L83-L119","documentation":"EventHubAdapterReceiver rejects a null EventHubPartitionSettings because it contains the EventHubOptions (Hub), the partition name, and the EventHubReceiverOptions — all three are needed to create the underlying Event Hub receiver and to initialize the partition during the Initialize call. Without settings the receiver cannot determine which partition to read from or how to connect to Event Hub.","triggerScenarios":"Constructing EventHubAdapterReceiver directly with a null settings argument. In the normal factory path (EventHubAdapterFactory.MakeReceiver), settings is built as a new EventHubPartitionSettings { Hub = ehOptions, Partition = ..., ReceiverOptions = ... } and is always non-null. Fires on manual construction or in test helpers.","commonSituations":"Writing integration tests that construct EventHubAdapterReceiver directly; a custom adapter factory that does not properly populate EventHubPartitionSettings before creating the receiver; a race condition or coding error where settings is initialized to null and never set.","solutions":["Always construct EventHubPartitionSettings with Hub, Partition, and ReceiverOptions set before passing it to the receiver constructor.","Use EventHubAdapterFactory.MakeReceiver/GetOrCreateReceiver rather than constructing EventHubAdapterReceiver directly.","In tests, create a valid EventHubPartitionSettings with test EventHubOptions configured via ConfigureEventHubConnection."],"exampleFix":"// before\nvar receiver = new EventHubAdapterReceiver(\n    null /* settings */, cacheFactory, checkpointerFactory, ...);\n\n// after\nvar settings = new EventHubPartitionSettings\n{\n    Hub = ehOptions,\n    Partition = \"0\",\n    ReceiverOptions = new EventHubReceiverOptions()\n};\nvar receiver = new EventHubAdapterReceiver(\n    settings, cacheFactory, checkpointerFactory, ...);","handlingStrategy":"validation","validationCode":"// Validate EventHubPartitionSettings before constructing the receiver:\nif (settings is null || settings.Hub is null || string.IsNullOrWhiteSpace(settings.Partition))\n    throw new InvalidOperationException(\n        \"EventHubPartitionSettings must have Hub and Partition set.\");","typeGuard":"static bool IsValidPartitionSettings(EventHubPartitionSettings settings)\n    => settings is not null\n       && settings.Hub is not null\n       && !string.IsNullOrWhiteSpace(settings.Partition)\n       && settings.ReceiverOptions is not null;","tryCatchPattern":null,"preventionTips":["Use EventHubAdapterFactory.MakeReceiver/GetOrCreateReceiver instead of constructing EventHubAdapterReceiver directly.","Always populate Hub, Partition, and ReceiverOptions when constructing EventHubPartitionSettings.","In tests, create settings from a properly configured EventHubOptions."],"tags":["configuration","eventhub","constructor","null-argument","receiver","partition-settings"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}