{"record":{"id":"ab17f6ea8690c924","repo":"jstedfast/MailKit","slug":"the-imapfolder-does-not-support-mod-sequences-ab17f6","errorCode":null,"errorMessage":"The ImapFolder does not support mod-sequences.","messagePattern":"The ImapFolder does not support mod-sequences\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapFolderFetch.cs","lineNumber":1096,"sourceCode":"\t\t\t\tMessageExpunged -= sctx.OnMessageExpunged;\n\t\t\t}\n\t\t}\n\n\t\tinternal static bool IsEmptyFetchRequest (IFetchRequest request)\n\t\t{\n\t\t\treturn request.Items == MessageSummaryItems.None && (request.Headers == null || (request.Headers.Count == 0 && !request.Headers.Exclude));\n\t\t}\n\n\t\tbool CheckCanFetch (IList<UniqueId> uids, IFetchRequest request)\n\t\t{\n\t\t\tif (uids == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (uids));\n\n\t\t\tif (request == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (request));\n\n\t\t\tif (request.ChangedSince.HasValue && !supportsModSeq)\n\t\t\t\tthrow new NotSupportedException (\"The ImapFolder does not support mod-sequences.\");\n\n\t\t\tif (request.PartialRange.HasValue && (Engine.Capabilities & ImapCapabilities.Partial) == 0)\n\t\t\t\tthrow new NotSupportedException (\"The IMAP server does not support the PARTIAL extension.\");\n\n\t\t\tCheckState (true, false);\n\n\t\t\treturn uids.Count > 0 && !IsEmptyFetchRequest (request);\n\t\t}\n\n\t\tstring CreateFetchCommand (IList<UniqueId> uids, IFetchRequest request, out bool previewText)\n\t\t{\n\t\t\tvar query = FormatSummaryItems (Engine, request, out previewText);\n\t\t\tvar command = new StringBuilder (\"UID FETCH %s \");\n\n\t\t\tcommand.Append (query);\n\n\t\t\tif (request.ChangedSince.HasValue || request.PartialRange.HasValue) {\n\t\t\t\tcommand.Append (\" (\");","sourceCodeStart":1078,"sourceCodeEnd":1114,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapFolderFetch.cs#L1078-L1114","documentation":"CheckCanFetch(IList<UniqueId>, IFetchRequest) — used by Fetch/FetchAsync by UID — throws this NotSupportedException when the fetch request sets ChangedSince but the folder's supportsModSeq flag is false. Fetching only messages changed since a mod-sequence requires the CONDSTORE extension (RFC 7162); MailKit validates this client-side instead of letting the server return BAD.","triggerScenarios":"Calling Fetch(IList<UniqueId> uids, IFetchRequest request) or FetchAsync where request.ChangedSince.HasValue and the IMAP server does not support CONDSTORE/QRESYNC (supportsModSeq == false).","commonSituations":"Implementing incremental sync (pull only changed messages since last known modseq) against Gmail, which lacks CONDSTORE; setting ChangedSince copied from sample sync code without checking capabilities; reconnecting to a different/misconfigured server that lost CONDSTORE.","solutions":["Check folder.SupportsModSeq before setting request.ChangedSince; if false, fall back to a full Fetch and diff client-side","Verify the ImapClient advertises CONDSTORE/QRESYNC (client.Capabilities) and that the server has the extension enabled","Clear the ChangedSince value on the IFetchRequest when unsupported"],"exampleFix":"// before\nvar request = new FetchRequest { Items = MessageSummaryItems.All, ChangedSince = lastModSeq };\nvar summaries = folder.Fetch(uids, request);\n// after\nif (folder.SupportsModSeq) {\n    request.ChangedSince = lastModSeq;\n} else {\n    request.ChangedSince = null; // full fetch + client-side diff\n}\nvar summaries = folder.Fetch(uids, request);","handlingStrategy":"validation","validationCode":"if (request.ChangedSince.HasValue && !folder.SupportsModSeq)\n    request.ChangedSince = null; // full fetch + client-side diff\nvar summaries = folder.Fetch(uids, request);","typeGuard":null,"tryCatchPattern":"try {\n    summaries = folder.Fetch(uids, request);\n} catch (NotSupportedException) {\n    request.ChangedSince = null;\n    summaries = folder.Fetch(uids, request); // fallback full fetch\n}","preventionTips":["Always gate ChangedSince on folder.SupportsModSeq","Cache per-connection capability detection results and re-check after reconnect","Design sync logic to work (slower) without CONDSTORE"],"tags":["imap","mailkit","not-supported","modseq","condstore","fetch"],"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-15T23:17:13.987Z"}