{"record":{"id":"a98c890e5087a433","repo":"dotnet/orleans","slug":"receiveroptions","errorCode":null,"errorMessage":"receiverOptions","messagePattern":"receiverOptions","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubAdapterFactory.cs","lineNumber":125,"sourceCode":"        public EventHubAdapterFactory(\n            string name,\n            EventHubOptions ehOptions,\n            EventHubReceiverOptions receiverOptions,\n            EventHubStreamCachePressureOptions cacheOptions, \n            StreamCacheEvictionOptions cacheEvictionOptions,\n            StreamStatisticOptions statisticOptions,\n            IEventHubDataAdapter dataAdapter,\n            IServiceProvider serviceProvider,\n            ILoggerFactory loggerFactory,\n            IEnvironmentStatisticsProvider environmentStatisticsProvider)\n        {\n            this.Name = name;\n            this.cacheEvictionOptions = cacheEvictionOptions ?? throw new ArgumentNullException(nameof(cacheEvictionOptions));\n            this.statisticOptions = statisticOptions ?? throw new ArgumentNullException(nameof(statisticOptions));\n            this.ehOptions = ehOptions ?? throw new ArgumentNullException(nameof(ehOptions));\n            this.cacheOptions = cacheOptions?? throw new ArgumentNullException(nameof(cacheOptions));\n            this.dataAdapter = dataAdapter ?? throw new ArgumentNullException(nameof(dataAdapter));\n            this.receiverOptions = receiverOptions?? throw new ArgumentNullException(nameof(receiverOptions));\n            this.serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));\n            this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));\n            this.environmentStatisticsProvider = environmentStatisticsProvider;\n            this.orleansInstruments = serviceProvider.GetRequiredService<OrleansInstruments>();\n        }\n\n        public virtual void Init()\n        {\n            this.receivers = new ConcurrentDictionary<QueueId, EventHubAdapterReceiver>();\n\n            InitEventHubClient();\n\n            if (this.CacheFactory == null)\n            {\n                this.CacheFactory = CreateCacheFactory(this.cacheOptions).CreateCache;\n            }\n\n            if (this.StreamFailureHandlerFactory == null)","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubAdapterFactory.cs#L107-L143","documentation":"EventHubAdapterFactory requires a non-null EventHubReceiverOptions because these options control receiver prefetch count and the StartFromNow behavior (whether to begin reading from the most recent events or the beginning of a partition when no checkpoint exists). Without it the adapter cannot configure individual Event Hub partition receivers during GetOrCreateReceiver calls.","triggerScenarios":"Constructing EventHubAdapterFactory directly with receiverOptions set to null. In the default factory Create path this is resolved via services.GetOptionByName<EventHubReceiverOptions>(name), which returns a non-null default (PrefetchCount=null, StartFromNow=true). Fires only on manual construction or a custom factory passing null.","commonSituations":"Manual construction in tests or a custom factory bypassing the standard Create method; a DI container misconfiguration where named EventHubReceiverOptions are overridden with null; a custom EventHubAdapterFactory subclass that incorrectly initializes the receiver options.","solutions":["If constructing manually, pass new EventHubReceiverOptions() (defaults: StartFromNow=true, PrefetchCount=null).","If using standard DI, ensure AddEventHubStreams is registered so that named EventHubReceiverOptions are available.","If overriding EventHubReceiverOptions via configure, verify the configuration callback does not set the options instance to null."],"exampleFix":"// before\nvar factory = new EventHubAdapterFactory(\n    name, ehOptions, null /* receiverOptions */, cacheOptions, ...);\n\n// after\nvar factory = new EventHubAdapterFactory(\n    name, ehOptions, new EventHubReceiverOptions(), cacheOptions, ...);","handlingStrategy":"validation","validationCode":"// Ensure receiverOptions is non-null before construction:\nvar receiverOptions = new EventHubReceiverOptions\n{\n    PrefetchCount = configuredPrefetch, // optional\n    StartFromNow = true // default\n};","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use GetOptionByName<EventHubReceiverOptions>(name) from the service provider which returns defaults.","When configuring receiver options via Configure<EventHubReceiverOptions>, do not set the instance to null.","Pass new EventHubReceiverOptions() in manual/test construction."],"tags":["configuration","dependency-injection","eventhub","constructor","null-argument","receiver-options"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}