{"record":{"id":"f25584e0692f1062","repo":"dotnet/orleans","slug":"unable-to-retrieve-messages-from-the-queue","errorCode":null,"errorMessage":"Unable to retrieve messages from the queue.","messagePattern":"Unable to retrieve messages from the queue\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"info","filePath":"src/AWS/Orleans.Streaming.SQS/Storage/SQSStorage.cs","lineNumber":203,"sourceCode":"        public async Task<IEnumerable<SQSMessage>> GetMessages(int count = 1)\n        {\n            try\n            {\n                if (string.IsNullOrWhiteSpace(queueUrl))\n                    throw new InvalidOperationException(\"Queue not initialized\");\n\n                if (count < 1)\n                    throw new ArgumentOutOfRangeException(nameof(count));\n\n                var request = new ReceiveMessageRequest { QueueUrl = queueUrl, MaxNumberOfMessages = count <= MAX_NUMBER_OF_MESSAGE_TO_PEEK ? count : MAX_NUMBER_OF_MESSAGE_TO_PEEK };\n                var response = await sqsClient.ReceiveMessageAsync(request);\n                return response.Messages;\n            }\n            catch (Exception exc)\n            {\n                ReportErrorAndRethrow(exc, \"GetMessages\");\n            }\n            throw new InvalidOperationException(\"Unable to retrieve messages from the queue.\");\n        }\n\n        /// <summary>\n        /// Delete a message from SQS queue\n        /// </summary>\n        /// <param name=\"message\">The message to be deleted</param>\n        /// <returns></returns>\n        public async Task DeleteMessage(SQSMessage message)\n        {\n            try\n            {\n                if (message == null)\n                    throw new ArgumentNullException(nameof(message));\n\n                if (string.IsNullOrWhiteSpace(message.ReceiptHandle))\n                    throw new ArgumentNullException(nameof(message.ReceiptHandle));\n\n                if (string.IsNullOrWhiteSpace(queueUrl))","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AWS/Orleans.Streaming.SQS/Storage/SQSStorage.cs#L185-L221","documentation":"This is a structurally unreachable trailing throw in GetMessages. The try block either returns response.Messages or throws; any exception is caught and ReportErrorAndRethrow always rethrows as an AggregateException. Because the catch path never returns normally, control can never fall through to this final throw. It exists only to satisfy the compiler that the method returns a value on all paths.","triggerScenarios":"Effectively unreachable in current code. It could only execute if ReportErrorAndRethrow were changed to stop throwing, or if the try block were edited to complete without returning.","commonSituations":"Developers see this message in a stack trace only when misattributing the real exception; the actual failure is the AggregateException from ReportErrorAndRethrow (e.g., network/AWS error). No realistic user action produces this exact throw.","solutions":["Treat any 'Unable to retrieve messages from the queue.' sighting as misattributed; inspect the inner exception of the AggregateException from ReportErrorAndRethrow for the real cause.","If you are maintaining this file, consider replacing the catch+throw tail with 'throw;' or marking ReportErrorAndRethrow as [DoesNotReturn] to remove the dead code.","Fix the underlying SQS error (credentials, region, queue URL) that the wrapped exception reports."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// The trailing throw is unreachable; real failures surface as AggregateException.\ntry { var msgs = await storage.GetMessages(count); }\ncatch (AggregateException ex)\n{\n    var root = ex.InnerExceptions.Count > 0 ? ex.InnerExceptions[0] : ex.InnerException;\n    logger.LogError(root, \"GetMessages failed for queue {Queue}\", storage.QueueName);\n    throw;\n}","preventionTips":["Do not rely on this message as a real signal; inspect the AggregateException inner exception.","If maintaining the file, annotate ReportErrorAndRethrow with [DoesNotReturn] to remove the dead throw.","Report any genuine occurrence upstream as a provider bug."],"tags":["aws","sqs","dead-code","unreachable","orleans"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}