dotnet/orleans · error · ArgumentNullException
service
Error message
service
What it means
Thrown by the DynamoDBStorage constructor when the service argument (the AWS region/service identifier, e.g. 'us-west-2') is null. The constructor uses nameof(service) so the thrown ArgumentNullException reports the parameter name 'service'. service drives RegionEndpoint selection in CreateClient, so a null value cannot proceed.
Source
Thrown at src/AWS/Shared/Storage/DynamoDBStorage.cs:85
/// <param name="readCapacityUnits"></param>
/// <param name="writeCapacityUnits"></param>
/// <param name="useProvisionedThroughput"></param>
/// <param name="createIfNotExists"></param>
/// <param name="updateIfExists"></param>
public DynamoDBStorage(
ILogger logger,
string service,
string? accessKey = "",
string? secretKey = "",
string? token = "",
string? profileName = "",
int readCapacityUnits = DefaultReadCapacityUnits,
int writeCapacityUnits = DefaultWriteCapacityUnits,
bool useProvisionedThroughput = true,
bool createIfNotExists = true,
bool updateIfExists = true)
{
if (service == null) throw new ArgumentNullException(nameof(service));
this._accessKey = accessKey;
this.secretKey = secretKey;
this._token = token;
this._profileName = profileName;
this._service = service;
this._useProvisionedThroughput = useProvisionedThroughput;
this._provisionedThroughput = this._useProvisionedThroughput
? new ProvisionedThroughput(readCapacityUnits, writeCapacityUnits)
: null;
this._createIfNotExists = createIfNotExists;
this._updateIfExists = updateIfExists;
_logger = logger;
CreateClient();
}
/// <summary>
/// Create a DynamoDB table if it doesn't exist
/// </summary>View on GitHub (pinned to fca799fa70)
Solutions
- Set the Service/Region in the DynamoDB options (the AWS region system name, e.g. 'us-west-2').
- If the region comes from configuration/environment, validate it is non-null before building the silo.
- Provide a sensible default in your bootstrap code (e.g., fallback to a known region).
- Check the specific options section (clustering vs persistence vs reminders vs transactions) that corresponds to the failing provider.
Example fix
// before: Service not set
silo.AddDynamoDBTransactionalGrainStorage("tx", opt => { opt.TableName = "tx"; });
// after: set the region
silo.AddDynamoDBTransactionalGrainStorage("tx", opt =>
{
opt.Service = Environment.GetEnvironmentVariable("AWS_REGION") ?? "us-west-2";
opt.TableName = "tx";
}); Defensive patterns
Strategy: validation
Validate before calling
// Resolve and validate the region before building the silo
var region = Environment.GetEnvironmentVariable("AWS_REGION")
?? config["DynamoDB:Service"]
?? "us-west-2";
if (string.IsNullOrWhiteSpace(region))
throw new InvalidOperationException("AWS region (Service) must be configured for DynamoDB storage"); Type guard
static bool HasService(string? service) => !string.IsNullOrWhiteSpace(service);
Try / catch
try { silo.StartAsync(); }
catch (ArgumentNullException an) when (an.ParamName == "service")
{
_logger.LogCritical("DynamoDB 'Service' (region) is null; set it in DynamoDBStorageOptions");
throw;
} Prevention
- Always set the Service (region) property in DynamoDB options.
- Read region from a validated config/env source with a default fallback.
- Unit-test config binding to ensure the DynamoDB section is populated.
- Distinguish the region (Service) from credentials in config templates.
When it happens
Trigger: Produced when constructing DynamoDBStorage (directly, or via a provider factory that passes options.Service) with service == null. Triggered by missing/empty 'Service' in DynamoDBStorageOptions / DynamoDBTransactionalStorageOptions / clustering/reminders options, or by a null being explicitly passed.
Common situations: Forgetting to set the 'Service' (region) property in configuration; reading the region from an environment variable/secret that resolved to null; misconfigured appsettings.json section; a test helper that constructs DynamoDBStorage without a region.
Related errors
- Table {tableDescription.TableName} has a status of {tableDes
- Configuration for DynamoDBGrainStorage {name} is invalid. Ta
- Configuration for DynamoDBGrainStorage {name} is invalid. Re
- Configuration for DynamoDBGrainStorage {name} is invalid. Wr
- Data too large to write to DynamoDB table. Size={dataSize} M
AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13).
Data as JSON: /api/errors/9b60c8bb043de20d.
Report an issue: GitHub.