{"record":{"id":"2e826b07dda7799d","repo":"dotnet/orleans","slug":"message","errorCode":null,"errorMessage":"message","messagePattern":"message","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/AWS/Orleans.Streaming.SQS/Storage/SQSStorage.cs","lineNumber":216,"sourceCode":"            }\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))\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        {","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AWS/Orleans.Streaming.SQS/Storage/SQSStorage.cs#L198-L234","documentation":"Thrown by SQSStorage.DeleteMessage when the supplied SQSMessage is null. The provider needs a non-null message because it reads ReceiptHandle and queues the deletion against queueUrl; a null reference would otherwise produce a NullReferenceException deeper in the call.","triggerScenarios":"Passing a null SQSMessage to DeleteMessage, e.g., deleting the result of a lookup that returned null, or forwarding a null from a dequeue that yielded no message.","commonSituations":"Message-handling loops that call DeleteMessage on a possibly-empty peek result; adapters that lose a message reference during error paths; tests that pass null by mistake.","solutions":["Null-check before deleting: if (message is null) return; or skip.","Ensure the upstream dequeue/GetMessages actually returned a message before attempting deletion.","Guard at the adapter boundary so null never reaches DeleteMessage.","Add a unit test asserting DeleteMessage rejects null cleanly."],"exampleFix":"// before\nawait storage.DeleteMessage(null); // throws\n\n// after\nif (message is not null)\n    await storage.DeleteMessage(message);","handlingStrategy":"type-guard","validationCode":"if (message is null) { logger.LogDebug(\"DeleteMessage skipped: null message.\"); return; }\nawait storage.DeleteMessage(message);","typeGuard":"static bool IsDeletable(SQSMessage? m) => m is not null;","tryCatchPattern":"try { await storage.DeleteMessage(message); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"message\")\n{\n    logger.LogDebug(\"Ignored null message in DeleteMessage.\");\n}","preventionTips":["Null-check messages at the dequeue boundary.","Never delete from a possibly-empty peek result.","Add a precondition contract on message-processing handlers."],"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"}