{"record":{"id":"f93c6f46817a7e12","repo":"jstedfast/MailKit","slug":"message","errorCode":null,"errorMessage":"message","messagePattern":"message","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"MailKit/AppendRequest.cs","lineNumber":103,"sourceCode":"\t\t\tFlags = flags;\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Initializes a new instance of the <see cref=\"AppendRequest\"/> class.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// Creates a new <see cref=\"AppendRequest\"/>.\n\t\t/// </remarks>\n\t\t/// <param name=\"message\">The message.</param>\n\t\t/// <param name=\"flags\">The message flags.</param>\n\t\t/// <param name=\"internalDate\">The internal date of the message.</param>\n\t\t/// <exception cref=\"ArgumentNullException\">\n\t\t/// <paramref name=\"message\"/> is <see langword=\"null\" />.\n\t\t/// </exception>\n\t\tpublic AppendRequest (MimeMessage message, MessageFlags flags, DateTimeOffset internalDate)\n\t\t{\n\t\t\tif (message == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (message));\n\n\t\t\tMessage = message;\n\t\t\tFlags = flags;\n\t\t\tInternalDate = internalDate;\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Initializes a new instance of the <see cref=\"AppendRequest\"/> class.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// Creates a new <see cref=\"AppendRequest\"/>.\n\t\t/// </remarks>\n\t\t/// <param name=\"message\">The message.</param>\n\t\t/// <param name=\"flags\">The message flags.</param>\n\t\t/// <param name=\"keywords\">The message keywords.</param>\n\t\t/// <param name=\"internalDate\">The internal date of the message.</param>\n\t\t/// <exception cref=\"ArgumentNullException\">\n\t\t/// <para><paramref name=\"message\"/> is <see langword=\"null\" />.</para>","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/AppendRequest.cs#L85-L121","documentation":"MailKit's AppendRequest(MimeMessage, MessageFlags, DateTimeOffset) constructor throws ArgumentNullException when the message parameter is null. The message is the MIME content to upload via IMAP APPEND, so it is mandatory. A null message cannot be serialized and is rejected immediately.","triggerScenarios":"Calling new AppendRequest(null, flags, internalDate) — e.g. a MimeMessage variable from a failed parse (MimeMessage.Load returning null in custom code), or a method parameter passed straight through without a null check.","commonSituations":"Message-loading code that swallows exceptions and returns null; refactoring where the message is conditionally created; forwarding a message retrieved from another API that may return null.","solutions":["Ensure a valid MimeMessage instance is created/loaded before constructing AppendRequest.","If the message may be absent, guard the append operation behind a null check and skip or log instead.","Fix the upstream loader so it throws a meaningful exception rather than returning null."],"exampleFix":"// before\nMimeMessage msg = LoadMessage(path); // may return null\nvar req = new AppendRequest(msg, MessageFlags.None, DateTimeOffset.Now);\n\n// after\nvar msg = LoadMessage(path) ?? throw new InvalidOperationException($\"Could not load message at {path}\");\nvar req = new AppendRequest(msg, MessageFlags.None, DateTimeOffset.Now);","handlingStrategy":"validation","validationCode":"if (message == null)\n    throw new InvalidOperationException(\"Cannot append: message was not loaded\");\nvar req = new AppendRequest(message, flags, internalDate);","typeGuard":"bool IsValidMessage(MimeMessage message) => message != null;","tryCatchPattern":"try\n{\n    var req = new AppendRequest(message, flags, internalDate);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"message\")\n{\n    logger.LogError(ex, \"Null MimeMessage passed to AppendRequest\");\n}","preventionTips":["Never let message loaders return null; throw on failure instead.","Validate loaded messages immediately after loading, before further use.","Use nullable reference types and null-forgiveness checks in the message pipeline."],"tags":["argument-null","imap","append","mailkit"],"backgroundTag":"null-argument","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}