{"record":{"id":"5f1263f39ae63852","repo":"dotnet/orleans","slug":"receipthandle","errorCode":null,"errorMessage":"ReceiptHandle","messagePattern":"ReceiptHandle","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/AWS/Orleans.Streaming.SQS/Storage/SQSStorage.cs","lineNumber":219,"sourceCode":"                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))\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        }","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AWS/Orleans.Streaming.SQS/Storage/SQSStorage.cs#L201-L237","documentation":"Thrown by SQSStorage.DeleteMessage when message.ReceiptHandle is null/empty/whitespace. SQS deletion requires a valid ReceiptHandle (issued when the message was received); without it AWS cannot identify which reception to acknowledge, so the provider rejects the call before contacting SQS.","triggerScenarios":"Deleting an SQSMessage that was constructed manually without a ReceiptHandle, deleting a message whose ReceiptHandle expired, or deleting an object populated from a partial/older payload where ReceiptHandle was never set.","commonSituations":"Reusing a message object across the visibility-timeout boundary after the handle lapsed; deserializing a stored message without its handle; test fixtures that build SQSMessage instances by hand.","solutions":["Only delete messages freshly obtained from GetMessages so ReceiptHandle is populated.","Delete within the SQS visibility timeout before the handle becomes invalid.","If you build SQSMessage manually, set ReceiptHandle from a valid receive operation.","Add a guard: if (string.IsNullOrWhiteSpace(msg.ReceiptHandle)) skip and log."],"exampleFix":"// before\nvar msg = new SQSMessage { Body = payload }; // no ReceiptHandle\nawait storage.DeleteMessage(msg); // throws\n\n// after\nvar received = (await storage.GetMessages(1)).First(); // has ReceiptHandle\nawait storage.DeleteMessage(received);","handlingStrategy":"validation","validationCode":"if (message is null || string.IsNullOrWhiteSpace(message.ReceiptHandle))\n{\n    logger.LogWarning(\"Cannot delete SQS message: missing ReceiptHandle.\");\n    return;\n}\nawait storage.DeleteMessage(message);","typeGuard":"static bool HasReceiptHandle(SQSMessage m) => !string.IsNullOrWhiteSpace(m?.ReceiptHandle);","tryCatchPattern":"try { await storage.DeleteMessage(message); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"ReceiptHandle\")\n{\n    logger.LogWarning(\"Delete skipped: SQS message has no ReceiptHandle.\");\n}","preventionTips":["Only delete messages you just received from GetMessages.","Delete within the visibility timeout.","Never build SQSMessage by hand for deletion."],"tags":["aws","sqs","streaming","argument-validation","orleans"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}