{"record":{"id":"ad00c99b7b833008","repo":"jstedfast/MailKit","slug":"status","errorCode":null,"errorMessage":"STATUS","messagePattern":"STATUS","errorType":"exception","errorClass":"ImapProtocolException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapEngine.cs","lineNumber":2688,"sourceCode":"\t\tvoid UpdateStatus (CancellationToken cancellationToken)\n\t\t{\n\t\t\tvar token = ReadToken (ImapStream.AtomSpecials, cancellationToken);\n\t\t\tstring name;\n\n\t\t\tswitch (token.Type) {\n\t\t\tcase ImapTokenType.Literal:\n\t\t\t\tname = ReadLiteral (cancellationToken);\n\t\t\t\tbreak;\n\t\t\tcase ImapTokenType.QString:\n\t\t\tcase ImapTokenType.Atom:\n\t\t\t\tname = (string) token.Value;\n\t\t\t\tbreak;\n\t\t\tcase ImapTokenType.Nil:\n\t\t\t\t// Note: according to rfc3501, section 4.5, NIL is acceptable as a mailbox name.\n\t\t\t\tname = (string) token.Value;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow UnexpectedToken (GenericUntaggedResponseSyntaxErrorFormat, \"STATUS\", token);\n\t\t\t}\n\n\t\t\t// Note: if the folder is null, then it probably means the user is using NOTIFY\n\t\t\t// and hasn't yet requested the folder. That's ok.\n\t\t\tTryGetCachedFolder (name, out var folder);\n\n\t\t\ttoken = ReadToken (cancellationToken);\n\n\t\t\tAssertToken (token, ImapTokenType.OpenParen, GenericUntaggedResponseSyntaxErrorFormat, \"STATUS\", token);\n\n\t\t\tdo {\n\t\t\t\ttoken = ReadToken (cancellationToken);\n\n\t\t\t\tif (token.Type == ImapTokenType.CloseParen)\n\t\t\t\t\tbreak;\n\n\t\t\t\tAssertToken (token, ImapTokenType.Atom, GenericUntaggedResponseSyntaxErrorFormat, \"STATUS\", token);\n","sourceCodeStart":2670,"sourceCodeEnd":2706,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapEngine.cs#L2670-L2706","documentation":"Thrown when parsing an untagged STATUS response: the mailbox name token was not an atom, quoted string, or NIL as allowed by RFC 3501, so the STATUS response is syntactically invalid. MailKit rejects the malformed token instead of misinterpreting the response.","triggerScenarios":"Server sends `* STATUS <bad-token> (...)` where the mailbox name is something other than a valid atom, quoted string, or NIL — encountered while processing unsolicited or requested STATUS responses during ImapClient operations (e.g. GetFolder status queries, IDLE with NOTIFY).","commonSituations":"Broken or experimental server implementations emitting raw or unquoted strings with special characters in mailbox names; servers not quoting names containing spaces or non-ASCII (UTF-7/UTF-8) characters; proxies corrupting the response.","solutions":["Capture the protocol log to see the exact STATUS response line that failed","Check whether the mailbox name contains characters that require quoting; verify the server quotes them per RFC 3501","Test with a reference server (Dovecot) to confirm which side is non-compliant","Upgrade MailKit in case parser handling of mailbox-name encodings (UTF-8/UTF-7) has improved","If you control the server, fix it to emit atom, quoted string, or NIL for the mailbox name"],"exampleFix":"// before\n// server: * STATUS INBOX (MESSAGES 5)   <- name with spaces unquoted\n// after\n// server: * STATUS \"My Inbox\" (MESSAGES 5)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    var status = folder.Status (StatusItems.Count);\n} catch (ImapProtocolException ex) {\n    logger.LogError (ex, \"Malformed STATUS response from server\");\n    // degrade: fall back to Examine/GetFolder information\n}","preventionTips":["Enable protocol logging once per environment to catch non-compliant STATUS output early","Ensure mailbox names with spaces/Unicode are handled by a compliant server (quoted strings / modified UTF-7)","Test folder names containing special characters against your server before rollout","Keep MailKit updated"],"tags":["imap","status-response","protocol-parse"],"backgroundTag":"unexpected-response-shape","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}