dotnet/orleans · error · ArgumentNullException

receiverOptions

Error message

receiverOptions

What it means

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.

Source

Thrown at src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubAdapterFactory.cs:125

        public EventHubAdapterFactory(
            string name,
            EventHubOptions ehOptions,
            EventHubReceiverOptions receiverOptions,
            EventHubStreamCachePressureOptions cacheOptions, 
            StreamCacheEvictionOptions cacheEvictionOptions,
            StreamStatisticOptions statisticOptions,
            IEventHubDataAdapter dataAdapter,
            IServiceProvider serviceProvider,
            ILoggerFactory loggerFactory,
            IEnvironmentStatisticsProvider environmentStatisticsProvider)
        {
            this.Name = name;
            this.cacheEvictionOptions = cacheEvictionOptions ?? throw new ArgumentNullException(nameof(cacheEvictionOptions));
            this.statisticOptions = statisticOptions ?? throw new ArgumentNullException(nameof(statisticOptions));
            this.ehOptions = ehOptions ?? throw new ArgumentNullException(nameof(ehOptions));
            this.cacheOptions = cacheOptions?? throw new ArgumentNullException(nameof(cacheOptions));
            this.dataAdapter = dataAdapter ?? throw new ArgumentNullException(nameof(dataAdapter));
            this.receiverOptions = receiverOptions?? throw new ArgumentNullException(nameof(receiverOptions));
            this.serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
            this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
            this.environmentStatisticsProvider = environmentStatisticsProvider;
            this.orleansInstruments = serviceProvider.GetRequiredService<OrleansInstruments>();
        }

        public virtual void Init()
        {
            this.receivers = new ConcurrentDictionary<QueueId, EventHubAdapterReceiver>();

            InitEventHubClient();

            if (this.CacheFactory == null)
            {
                this.CacheFactory = CreateCacheFactory(this.cacheOptions).CreateCache;
            }

            if (this.StreamFailureHandlerFactory == null)

View on GitHub (pinned to fca799fa70)

Solutions

  1. If constructing manually, pass new EventHubReceiverOptions() (defaults: StartFromNow=true, PrefetchCount=null).
  2. If using standard DI, ensure AddEventHubStreams is registered so that named EventHubReceiverOptions are available.
  3. If overriding EventHubReceiverOptions via configure, verify the configuration callback does not set the options instance to null.

Example fix

// before
var factory = new EventHubAdapterFactory(
    name, ehOptions, null /* receiverOptions */, cacheOptions, ...);

// after
var factory = new EventHubAdapterFactory(
    name, ehOptions, new EventHubReceiverOptions(), cacheOptions, ...);
Defensive patterns

Strategy: validation

Validate before calling

// Ensure receiverOptions is non-null before construction:
var receiverOptions = new EventHubReceiverOptions
{
    PrefetchCount = configuredPrefetch, // optional
    StartFromNow = true // default
};

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13). Data as JSON: /api/errors/a98c890e5087a433. Report an issue: GitHub.