dotnet/orleans · error · ArgumentNullException
settings
Error message
settings
What it means
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.
Source
Thrown at src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubAdapterReceiver.cs:101
(partition, _) => checkpointerFactory(partition),
loggerFactory,
monitor,
loadSheddingOptions,
environmentStatisticsProvider,
eventHubReceiverFactory)
{
}
public EventHubAdapterReceiver(EventHubPartitionSettings settings,
Func<string, IStreamQueueCheckpointer<string>, ILoggerFactory, IEventHubQueueCache> cacheFactory,
Func<string, CancellationToken, Task<IStreamQueueCheckpointer<string>>> checkpointerFactory,
ILoggerFactory loggerFactory,
IQueueAdapterReceiverMonitor monitor,
LoadSheddingOptions loadSheddingOptions,
IEnvironmentStatisticsProvider environmentStatisticsProvider,
Func<EventHubPartitionSettings, string, ILogger, IEventHubReceiver>? eventHubReceiverFactory = null)
{
this.settings = settings ?? throw new ArgumentNullException(nameof(settings));
this.cacheFactory = cacheFactory ?? throw new ArgumentNullException(nameof(cacheFactory));
this.checkpointerFactory = checkpointerFactory ?? throw new ArgumentNullException(nameof(checkpointerFactory));
this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
this.logger = this.loggerFactory.CreateLogger<EventHubAdapterReceiver>();
this.monitor = monitor ?? throw new ArgumentNullException(nameof(monitor));
this.loadSheddingOptions = loadSheddingOptions ?? throw new ArgumentNullException(nameof(loadSheddingOptions));
this.environmentStatisticsProvider = environmentStatisticsProvider;
this.eventHubReceiverFactory = eventHubReceiverFactory == null ? EventHubAdapterReceiver.CreateReceiver : eventHubReceiverFactory;
}
public async Task Initialize(TimeSpan timeout)
{
LogInfoInitializingEventHubPartition(this.settings.Hub.EventHubName, this.settings.Partition);
// if receiver was already running, do nothing
if (ReceiverRunning == Interlocked.Exchange(ref this.receiverState, ReceiverRunning))
{
return;View on GitHub (pinned to fca799fa70)
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.
Example fix
// before
var receiver = new EventHubAdapterReceiver(
null /* settings */, cacheFactory, checkpointerFactory, ...);
// after
var settings = new EventHubPartitionSettings
{
Hub = ehOptions,
Partition = "0",
ReceiverOptions = new EventHubReceiverOptions()
};
var receiver = new EventHubAdapterReceiver(
settings, cacheFactory, checkpointerFactory, ...); Defensive patterns
Strategy: validation
Validate before calling
// Validate EventHubPartitionSettings before constructing the receiver:
if (settings is null || settings.Hub is null || string.IsNullOrWhiteSpace(settings.Partition))
throw new InvalidOperationException(
"EventHubPartitionSettings must have Hub and Partition set."); Type guard
static bool IsValidPartitionSettings(EventHubPartitionSettings settings)
=> settings is not null
&& settings.Hub is not null
&& !string.IsNullOrWhiteSpace(settings.Partition)
&& settings.ReceiverOptions is not null; Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13).
Data as JSON: /api/errors/8e931d0b6353b05c.
Report an issue: GitHub.