dotnet/orleans · error · ArgumentNullException

queueId

Error message

queueId

What it means

Thrown by SQSAdapterReceiver.Create when the supplied QueueId.IsDefault is true. A default QueueId has no meaningful partition/queue identity, so the receiver cannot bind to a backing SQS queue; the factory rejects it immediately rather than constructing a receiver over an unnamed queue.

Source

Thrown at src/AWS/Orleans.Streaming.SQS/Streams/SQSAdapterReceiver.cs:30

namespace OrleansAWSUtils.Streams
{
    /// <summary>
    /// Receives batches of messages from a single partition of a message queue.
    /// </summary>
    internal partial class SQSAdapterReceiver : IQueueAdapterReceiver
    {
        private SQSStorage? queue;
        private long lastReadMessage;
        private Task? outstandingTask;
        private readonly ILogger logger;
        private readonly Serializer<SQSBatchContainer> serializer;


        public QueueId Id { get; private set; }

        public static IQueueAdapterReceiver Create(Serializer<SQSBatchContainer> serializer, ILoggerFactory loggerFactory, QueueId queueId, string dataConnectionString, string serviceId)
        {
            if (queueId.IsDefault) throw new ArgumentNullException(nameof(queueId));
            if (string.IsNullOrEmpty(dataConnectionString)) throw new ArgumentNullException(nameof(dataConnectionString));
            if (string.IsNullOrEmpty(serviceId)) throw new ArgumentNullException(nameof(serviceId));

            var queue = new SQSStorage(loggerFactory, queueId.ToString(), dataConnectionString, serviceId);
            return new SQSAdapterReceiver(serializer, loggerFactory, queueId, queue);
        }

        private SQSAdapterReceiver(Serializer<SQSBatchContainer> serializer, ILoggerFactory loggerFactory, QueueId queueId, SQSStorage queue)
        {
            if (queueId.IsDefault) throw new ArgumentNullException(nameof(queueId));
            if (queue == null) throw new ArgumentNullException(nameof(queue));

            Id = queueId;
            this.queue = queue;
            logger = loggerFactory.CreateLogger<SQSAdapterReceiver>();
            this.serializer = serializer;
        }

View on GitHub (pinned to fca799fa70)

Solutions

  1. Ensure the QueueId comes from a valid streamQueueMapper.GetQueueForStream result before calling Create.
  2. Validate !queueId.IsDefault in your mapper/adapter before invoking Create.
  3. Initialize all QueueId fields from configuration at startup.
  4. Add a unit test asserting receivers are only created for non-default queue ids.

Example fix

// before
var rcv = SQSAdapterReceiver.Create(serializer, lf, default, conn, svc); // throws

// after
var queueId = mapper.GetQueueForStream(streamId);
var rcv = SQSAdapterReceiver.Create(serializer, lf, queueId, conn, svc);
Defensive patterns

Strategy: validation

Validate before calling

if (queueId.IsDefault) throw new ArgumentException("QueueId must be non-default.", nameof(queueId));
var rcv = SQSAdapterReceiver.Create(serializer, lf, queueId, conn, svc);

Type guard

static bool IsUsableQueueId(QueueId id) => !id.IsDefault;

Try / catch

try { return SQSAdapterReceiver.Create(serializer, lf, queueId, conn, svc); }
catch (ArgumentNullException ex) when (ex.ParamName == "queueId")
{
    logger.LogError("Cannot create receiver: QueueId is default.");
    throw;
}

Prevention

When it happens

Trigger: Passing default(QueueId) or an uninitialized QueueId to Create, typically because a mapper returned a default or a field was never assigned before the receiver was created.

Common situations: Custom IConsistentRingStreamQueueMapper implementations that fall back to default(QueueId); serialization/deserialization paths that yield default; tests that hand-construct receivers without a real queue id.

Related errors


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