{"record":{"id":"faada321cf7601e5","repo":"jstedfast/MailKit","slug":"value-cannot-be-null-parameter-message","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'message')","messagePattern":"Value cannot be null\\. \\(Parameter 'message'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"warning","filePath":"MailKit/AlertEventArgs.cs","lineNumber":53,"sourceCode":"\t/// <see cref=\"MailKit.Net.Imap.ImapClient\"/>, will emit Alert\n\t/// events when they receive alert messages from the server.\n\t/// </remarks>\n\tpublic class AlertEventArgs : EventArgs\n\t{\n\t\t/// <summary>\n\t\t/// Initializes a new instance of the <see cref=\"MailKit.AlertEventArgs\"/> class.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// Creates a new <see cref=\"AlertEventArgs\"/>.\n\t\t/// </remarks>\n\t\t/// <param name=\"message\">The alert message.</param>\n\t\t/// <exception cref=\"System.ArgumentNullException\">\n\t\t/// <paramref name=\"message\"/> is <see langword=\"null\" />.\n\t\t/// </exception>\n\t\tpublic AlertEventArgs (string message)\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}\n\n\t\t/// <summary>\n\t\t/// Gets the alert message.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// The alert message will be the exact message received from the server.\n\t\t/// </remarks>\n\t\t/// <value>The alert message.</value>\n\t\tpublic string Message {\n\t\t\tget; private set;\n\t\t}\n\t}\n}\n","sourceCodeStart":35,"sourceCodeEnd":70,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/AlertEventArgs.cs#L35-L70","documentation":"The AlertEventArgs constructor stores the IMAP alert message and throws ArgumentNullException(nameof(message)) at MailKit/AlertEventArgs.cs:53 when message is null. This is an internal MailKit type used to surface server ALERT responses; the message text is the whole point of the event, so a null is rejected.","triggerScenarios":"Calling new AlertEventArgs(null) — normally only reachable from MailKit's own protocol handling when a server sends an untagged ALERT response with a null/empty text, or from test/user code constructing the args manually.","commonSituations":"A misbehaving or non-conformant IMAP server emitting an ALERT with no text; user code constructing AlertEventArgs directly in tests or custom protocol layers.","solutions":["If constructing manually, pass a non-empty string message.","If this surfaces from MailKit internals, check the server's untagged ALERT response — it is sending an empty message; report/patch the server behavior.","Wrap event subscription/processing in try-catch if a non-conformant server is involved and cannot be fixed."],"exampleFix":"// before\nvar args = new AlertEventArgs(serverAlertText); // null for empty ALERT\n\n// after\nvar args = new AlertEventArgs(string.IsNullOrEmpty(serverAlertText) ? \"(empty alert)\" : serverAlertText);","handlingStrategy":"try-catch","validationCode":"if (!string.IsNullOrEmpty(serverAlertText))\n    OnAlert(new AlertEventArgs(serverAlertText));","typeGuard":"bool HasAlertText(string msg) => !string.IsNullOrEmpty(msg);","tryCatchPattern":"try\n{\n    ProcessAlert(new AlertEventArgs(message));\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"message\")\n{\n    logger.LogWarning(\"Server sent an ALERT with no message text\");\n}","preventionTips":["Coerce empty server ALERT text to a placeholder string before constructing args","When hitting this from MailKit internals, investigate the server's untagged ALERT responses","Guard any code that constructs event args directly from protocol data"],"tags":["argument-null","imap","alert","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"}