dotnet/orleans · error · ArgumentNullException
Value cannot be null. (Parameter '{propertyName}')
Error message
Value cannot be null. (Parameter '{propertyName}') What it means
Thrown by AzureStoragePolicyOptions.SetIfValidTimeout when a timeout (CreationTimeout or OperationTimeout) is <= TimeSpan.Zero and not Timeout.InfiniteTimeSpan. NOTE: the library throws ArgumentNullException here, so the message reads 'Value cannot be null' even though the value is a non-null TimeSpan — this is misleading; the real problem is an invalid (non-positive, non-infinite) timeout. The parameter name reflects which property you set (CreationTimeout or OperationTimeout).
Source
Thrown at src/Azure/Shared/Storage/AzureStoragePolicyOptions.cs:82
get => this.creationTimeout ?? TimeSpan.FromMilliseconds(this.PauseBetweenCreationRetries.TotalMilliseconds * this.MaxCreationRetries * 3);
set => SetIfValidTimeout(ref this.creationTimeout, value, nameof(CreationTimeout));
}
public TimeSpan OperationTimeout
{
get => this.operationTimeout ?? TimeSpan.FromSeconds(100);
set => SetIfValidTimeout(ref this.operationTimeout, value, nameof(OperationTimeout));
}
private static void SetIfValidTimeout(ref TimeSpan? field, TimeSpan value, string propertyName)
{
if (value > TimeSpan.Zero || value.Equals(Timeout.InfiniteTimeSpan))
{
field = value;
}
else
{
throw new ArgumentNullException(propertyName);
}
}
}
}
View on GitHub (pinned to fca799fa70)
Solutions
- Set a positive TimeSpan or Timeout.InfiniteTimeSpan.
- Leave the property unset to use the defaults (OperationTimeout ~100s; CreationTimeout derived from creation retry settings).
- Treat the misleading 'Value cannot be null' message as 'invalid timeout value'.
Example fix
// before policy.OperationTimeout = TimeSpan.Zero; // throws (misleading 'null' message) // after policy.OperationTimeout = TimeSpan.FromSeconds(30); // or leave unset
Defensive patterns
Strategy: validation
Validate before calling
static TimeSpan SafeTimeout(TimeSpan v, string name) =>
v > TimeSpan.Zero || v == Timeout.InfiniteTimeSpan ? v : throw new ArgumentOutOfRangeException(name, "timeout must be positive or Infinite"); Type guard
static bool IsValidTimeout(TimeSpan v) => v > TimeSpan.Zero || v == Timeout.InfiniteTimeSpan;
Try / catch
catch (ArgumentNullException ex) when (ex.ParamName is "CreationTimeout" or "OperationTimeout") { /* misleading: value is invalid (<=0), not null; pass positive/Infinite */ } Prevention
- Read the misleading 'Value cannot be null' as 'invalid timeout value'.
- Leave timeouts unset to use defaults unless you need to tune them.
When it happens
Trigger: Setting policy.CreationTimeout or policy.OperationTimeout to TimeSpan.Zero or a negative value.
Common situations: Assuming TimeSpan.Zero means 'no timeout'; arithmetic that produces a non-positive duration; deserializing config that yields zero.
Related errors
- Value cannot be null. (Parameter 'createClientCallback')
- Value cannot be null. (Parameter 'connectionString')
- Value cannot be null. (Parameter 'serviceUri')
- Value cannot be null. (Parameter 'tokenCredential')
- Value cannot be null. (Parameter 'azureSasCredential')
AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13).
Data as JSON: /api/errors/beb2ec57572e3201.
Report an issue: GitHub.