{"record":{"id":"44d71adbdba342a4","repo":"dotnet/orleans","slug":"error-doing-operation-for-sqs-queue-queuename","errorCode":null,"errorMessage":"Error doing {operation} for SQS queue {QueueName}","messagePattern":"Error doing (.+?) for SQS queue (.+?)","errorType":"exception","errorClass":"AggregateException","httpStatus":null,"severity":"error","filePath":"src/AWS/Orleans.Streaming.SQS/Storage/SQSStorage.cs","lineNumber":236,"sourceCode":"                if (string.IsNullOrWhiteSpace(message.ReceiptHandle))\n                    throw new ArgumentNullException(nameof(message.ReceiptHandle));\n\n                if (string.IsNullOrWhiteSpace(queueUrl))\n                    throw new InvalidOperationException(\"Queue not initialized\");\n\n                await sqsClient.DeleteMessageAsync(\n                    new DeleteMessageRequest { QueueUrl = queueUrl, ReceiptHandle = message.ReceiptHandle });\n            }\n            catch (Exception exc)\n            {\n                ReportErrorAndRethrow(exc, \"DeleteMessage\");\n            }\n        }\n\n        private void ReportErrorAndRethrow(Exception exc, string operation)\n        {\n            LogErrorSQSOperation(exc, operation, QueueName);\n            throw new AggregateException($\"Error doing {operation} for SQS queue {QueueName}\", exc);\n        }\n\n        [LoggerMessage(\n            EventId = (int)ErrorCode.StreamProviderManagerBase,\n            Level = LogLevel.Error,\n            Message = \"Error doing {Operation} for SQS queue {QueueName}\"\n        )]\n        private partial void LogErrorSQSOperation(Exception exception, string operation, string queueName);\n    }\n}\n","sourceCodeStart":218,"sourceCodeEnd":247,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AWS/Orleans.Streaming.SQS/Storage/SQSStorage.cs#L218-L247","documentation":"This is the universal error wrapper in SQSStorage.ReportErrorAndRethrow. Every SQS operation (Init, Add, Get, Delete, DeleteQueue) funnels failures here: it logs via LogErrorSQSOperation and rethrows the original exception wrapped in an AggregateException whose message names the operation and queue. The message text is a format string interpolating {operation} (the method name) and {QueueName}.","triggerScenarios":"Any exception during an SQS call: AWS auth/credential failure, wrong region, throttling, network timeout, queue-not-found, malformed request, or an inner InvalidOperationException such as 'Queue not initialized'. All surface as this AggregateException.","commonSituations":"Bad/missing AWS credentials; wrong region in the connection string 'Service=' value; SQS throttling under load; localstack misconfiguration; the queueUrl-not-initialized errors (60/65) rethrown through this wrapper.","solutions":["Inspect AggregateException.InnerExceptions[0] (or .InnerException) for the real AWS error and address that.","Verify the connection string: AccessKey, SecretKey, and Service (region) are present and correct.","For throttling, reduce batch size / concurrency or request an SQS quota increase.","Confirm the IAM principal has sqs:* permissions on the queue ARN.","Reproduce locally with localstack to isolate credentials from network."],"exampleFix":"// before\ncatch (AggregateException ex)\n{\n    logger.LogError(ex, \"failed\"); // real cause buried\n}\n\n// after\ncatch (AggregateException ex)\n{\n    var root = ex.InnerExceptions.Count > 0 ? ex.InnerExceptions[0] : ex.InnerException;\n    logger.LogError(root, \"SQS {Op} failed for {Queue}\", op, queue);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await storage.GetMessages(count); }\ncatch (AggregateException ex)\n{\n    var root = ex.InnerExceptions.Count > 0 ? ex.InnerExceptions[0] : ex.InnerException;\n    // handle AmazonSQSException, AuthorizationException, timeout, etc.\n    logger.LogError(root, \"SQS operation failed for queue {Queue}\", storage.QueueName);\n    throw;\n}","preventionTips":["Always unwrap AggregateException.InnerExceptions to find the AWS root cause.","Verify credentials, region, and IAM sqs permissions.","Implement retry with backoff for transient AWS errors, not for auth failures."],"tags":["aws","sqs","streaming","error-handling","orleans"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}