dotnet/orleans · error · ArgumentNullException

dataConnectionString

Error message

dataConnectionString

What it means

Thrown by the SQSAdapter constructor when dataConnectionString is null or empty. The connection string carries AWS access key, secret key, and service/region; without it the adapter cannot build SQS clients. The provider fails fast at construction rather than failing later during streaming.

Solutions

  1. Set DataConnectionString in the SQS stream provider configuration (e.g., AddSQSStreams with a valid connection string).
  2. Confirm the config section is bound to SQSOptions and the key name matches exactly.
  3. Load environment-specific config (secrets manager, user secrets) before silo startup.
  4. Validate configuration at startup via IConfigurationValidator so this surfaces early.

Example fix

// before
silo.AddSQSStreams("SqsProvider", new SQSOptions()); // no DataConnectionString

// after
silo.AddSQSStreams("SqsProvider", new SQSOptions
{
    DataConnectionString = "Service=us-west-2;AccessKey=...;SecretKey=..."
});
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(dataConnectionString))
    throw new ArgumentException("SQS DataConnectionString is required.", nameof(dataConnectionString));

Type guard

static bool IsValidSqsConnectionString(string? s) => !string.IsNullOrWhiteSpace(s) && s.Contains('=');

Try / catch

try { /* construct adapter / host */ }
catch (ArgumentNullException ex) when (ex.ParamName == "dataConnectionString")
{
    logger.LogCritical("SQS stream provider is missing DataConnectionString in configuration.");
    throw;
}

Prevention

When it happens

Trigger: Configuring the SQS stream provider without a DataConnectionString, or passing a null/empty value from a missing configuration section. The adapter is typically constructed by the SQS stream provider from SQSOptions.

Common situations: Missing 'DataConnectionString' in appsettings/stream provider config; environment-specific config not loaded (e.g., user secrets in dev); misnamed key; empty value after substitution.

Related errors


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

Appendix: source

Thrown at src/AWS/Orleans.Streaming.SQS/Streams/SQSAdapter.cs:28

namespace OrleansAWSUtils.Streams
{
    internal class SQSAdapter : IQueueAdapter
    {
        protected readonly string ServiceId;
        private readonly Serializer<SQSBatchContainer> serializer;
        protected readonly string DataConnectionString;
        private readonly IConsistentRingStreamQueueMapper streamQueueMapper;
        protected readonly ConcurrentDictionary<QueueId, SQSStorage> Queues = new ConcurrentDictionary<QueueId, SQSStorage>();
        private readonly ILoggerFactory loggerFactory;
        public string Name { get; private set; }
        public bool IsRewindable { get { return false; } }

        public StreamProviderDirection Direction { get { return StreamProviderDirection.ReadWrite; } }

        public SQSAdapter(Serializer<SQSBatchContainer> serializer, IConsistentRingStreamQueueMapper streamQueueMapper, ILoggerFactory loggerFactory, string dataConnectionString, string serviceId, string providerName)
        {
            if (string.IsNullOrEmpty(dataConnectionString)) throw new ArgumentNullException(nameof(dataConnectionString));
            if (string.IsNullOrEmpty(serviceId)) throw new ArgumentNullException(nameof(serviceId));
            this.loggerFactory = loggerFactory;
            this.serializer = serializer;
            DataConnectionString = dataConnectionString;
            this.ServiceId = serviceId;
            Name = providerName;
            this.streamQueueMapper = streamQueueMapper;
        }

        public IQueueAdapterReceiver CreateReceiver(QueueId queueId)
        {
            return SQSAdapterReceiver.Create(this.serializer, this.loggerFactory, queueId, DataConnectionString, this.ServiceId);
        }

        public async Task QueueMessageBatchAsync<T>(StreamId streamId, IEnumerable<T> events, StreamSequenceToken? token, Dictionary<string, object>? requestContext)
        {
            if (token != null)
            {

View on GitHub (pinned to fca799fa70)