{"record":{"id":"65f1269833fd1cd1","repo":"jstedfast/MailKit","slug":"one-ore-more-requests-included-annotations-but-the-imap","errorCode":null,"errorMessage":"One ore more requests included annotations but the IMAP server does not support annotations.","messagePattern":"One ore more requests included annotations but the IMAP server does not support annotations\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapFolder.cs","lineNumber":4611,"sourceCode":"\n\t\t\treturn ProcessAppendResponse (ic);\n\t\t}\n\n\t\tvoid ValidateArguments (FormatOptions options, IList<IAppendRequest> requests)\n\t\t{\n\t\t\tif (options == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (options));\n\n\t\t\tif (requests == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (requests));\n\n\t\t\tfor (int i = 0; i < requests.Count; i++) {\n\t\t\t\tif (requests[i] == null)\n\t\t\t\t\tthrow new ArgumentException (\"One or more of the requests is null.\");\n\n\t\t\t\tvar annotations = requests[i].Annotations;\n\t\t\t\tif (annotations != null && annotations.Count > 0 && (Engine.Capabilities & ImapCapabilities.Annotate) == 0)\n\t\t\t\t\tthrow new NotSupportedException (\"One ore more requests included annotations but the IMAP server does not support annotations.\");\n\t\t\t}\n\n\t\t\tCheckState (false, false);\n\t\t}\n\n\t\tImapCommand QueueMultiAppendCommand (FormatOptions options, IList<IAppendRequest> requests, CancellationToken cancellationToken)\n\t\t{\n\t\t\tvar format = CreateAppendOptions (options);\n\t\t\tvar builder = new StringBuilder (\"APPEND %F\");\n\t\t\tvar list = new List<object> {\n\t\t\t\tthis\n\t\t\t};\n\n\t\t\tfor (int i = 0; i < requests.Count; i++) {\n\t\t\t\tvar keywords = requests[i].Keywords;\n\t\t\t\tint numKeywords = keywords != null ? keywords.Count : 0;\n\n\t\t\t\tbuilder.Append (' ');","sourceCodeStart":4593,"sourceCodeEnd":4629,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapFolder.cs#L4593-L4629","documentation":"The annotation request list contains annotations, but the connected IMAP server did not advertise the ANNOTATE capability (RFC 5257). MailKit refuses client-side rather than sending a command the server would fail. Thrown as NotSupportedException from the annotation argument-validation path in ImapFolder.","triggerScenarios":"Setting request.Annotations (non-empty) on a folder whose ImapClient.Capabilities lacks ImapCapabilities.Annotate, then calling SetAnnotations/Store with those requests.","commonSituations":"Developers assume all servers support annotations; connecting to Gmail/Exchange/outlook.com which do not implement ANNOTATE; capability check done once against a different server in a test environment.","solutions":["Check (imapClient.Capabilities & ImapCapabilities.Annotate) != 0 before attaching Annotations to requests","Strip the Annotations property from requests when the capability is missing, or skip annotation calls entirely","Verify you connected to the intended server (feature flags per environment)","Wrap in try/catch (NotSupportedException) to degrade gracefully"],"exampleFix":"// before\nrequest.Annotations = new[] { new Annotation(\"/comment\") { ... } };\nfolder.SetAnnotations(new[] { request });\n// after\nif ((client.Capabilities & ImapCapabilities.Annotate) != 0)\n    request.Annotations = new[] { new Annotation(\"/comment\") { ... } };\nfolder.SetAnnotations(new[] { request });","handlingStrategy":"validation","validationCode":"bool canAnnotate = (client.Capabilities & ImapCapabilities.Annotate) != 0;\nif (!canAnnotate)\n    requests = requests.Select(r => { r.Annotations = null; return r; }).ToList();","typeGuard":"bool SupportsAnnotate(ImapClient c) => (c.Capabilities & ImapCapabilities.Annotate) != 0;","tryCatchPattern":"try { folder.SetAnnotations(requests); }\ncatch (NotSupportedException) { log.LogWarning(\"Server lacks ANNOTATE; skipping annotations\"); }","preventionTips":["Always check server capabilities before using extension features","Per-environment capability flags in config","Read IMAP logs on first connect to confirm advertised capabilities"],"tags":["imap","capability","annotate","unsupported-feature"],"backgroundTag":"feature-not-enabled","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"}