{"record":{"id":"0d2b6e2f879a74a3","repo":"jstedfast/MailKit","slug":"mailkitlite-does-not-support-the-compress-extension","errorCode":null,"errorMessage":"MailKitLite does not support the COMPRESS extension.","messagePattern":"MailKitLite does not support the COMPRESS extension\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapClient.cs","lineNumber":298,"sourceCode":"\t\t\t\tsslValidationInfo = new SslCertificateValidationInfo (host, certificate, chain, sslPolicyErrors);\n\t\t\t}\n\n\t\t\treturn valid;\n\t\t}\n\n\t\tImapCommand QueueCompressCommand (CancellationToken cancellationToken)\n\t\t{\n\t\t\tCheckDisposed ();\n\t\t\tCheckConnected ();\n\n\t\t\tif ((engine.Capabilities & ImapCapabilities.Compress) == 0)\n\t\t\t\tthrow new NotSupportedException (\"The IMAP server does not support the COMPRESS extension.\");\n\n\t\t\tif (engine.State >= ImapEngineState.Selected)\n\t\t\t\tthrow new InvalidOperationException (\"Compression must be enabled before selecting a folder.\");\n\n#if MAILKIT_LITE\n\t\t\tthrow new NotSupportedException (\"MailKitLite does not support the COMPRESS extension.\");\n#else\n\t\t\treturn engine.QueueCommand (cancellationToken, null, \"COMPRESS DEFLATE\\r\\n\");\n#endif\n\t\t}\n\n\t\tvoid ProcessCompressResponse (ImapCommand ic)\n\t\t{\n#if !MAILKIT_LITE\n\t\t\tif (ic.Response != ImapCommandResponse.Ok) {\n\t\t\t\tfor (int i = 0; i < ic.RespCodes.Count; i++) {\n\t\t\t\t\tif (ic.RespCodes[i].Type == ImapResponseCodeType.CompressionActive)\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthrow ImapCommandException.Create (\"COMPRESS\", ic);\n\t\t\t}\n\n\t\t\tengine.Stream!.SetStream (new CompressedStream (engine.Stream.Stream));","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapClient.cs#L280-L316","documentation":"When MailKit is compiled with the MAILKIT_LITE symbol (the MailKitLite build that omits non-essential extensions), QueueCompressCommand always throws NotSupportedException because the DEFLATE compression code path is not compiled into the Lite package at all.","triggerScenarios":"Using the MailKitLite NuGet/package build and calling client.Compress() — the guard fires regardless of server capabilities.","commonSituations":"Migrating an app from full MailKit to MailKitLite (e.g. to reduce size or dependencies) while keeping compression calls; accidentally referencing the Lite variant when full MailKit was intended.","solutions":["Reference the full MailKit package instead of MailKitLite if COMPRESS is required","Remove/guard the Compress() call when targeting MailKitLite","Gate the call with a compile-time check or capability check so Lite builds skip compression"],"exampleFix":"// before\nclient.Compress(); // throws in MailKitLite\n// after (full MailKit only)\n#if !MAILKIT_LITE\nif ((client.Capabilities & ImapCapabilities.Compress) != 0)\n\tclient.Compress();\n#endif","handlingStrategy":"fallback","validationCode":"bool supportsCompress =\n#if MAILKIT_LITE\n\tfalse;\n#else\n\t(client.Capabilities & ImapCapabilities.Compress) != 0;\n#endif","typeGuard":null,"tryCatchPattern":"try {\n\tclient.Compress();\n} catch (NotSupportedException) {\n\t// Lite build or unsupported server: continue uncompressed\n}","preventionTips":["Pick MailKit vs MailKitLite deliberately based on required extensions","Wrap extension calls (COMPRESS, QRESYNC, etc.) in capability/compile-time guards","Document that Lite omits compression so ops don't chase server-side causes"],"tags":["mailkit-lite","compression","unsupported-feature","compile-time"],"backgroundTag":"unsupported-platform","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"}