{"record":{"id":"14761580e2853d2c","repo":"jstedfast/MailKit","slug":"no-event-groups-specified","errorCode":null,"errorMessage":"No event groups specified.","messagePattern":"No event groups specified\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapClient.cs","lineNumber":2018,"sourceCode":"\t\t\tif (doneToken.IsCancellationRequested)\n\t\t\t\treturn;\n\n\t\t\tusing (var context = new ImapIdleContext (engine, doneToken, cancellationToken)) {\n\t\t\t\tvar ic = QueueIdleCommand (context, cancellationToken);\n\n\t\t\t\tengine.Run (ic);\n\n\t\t\t\tProcessIdleResponse (ic);\n\t\t\t}\n\t\t}\n\n\t\tImapCommand QueueNotifyCommand (bool status, IList<ImapEventGroup> eventGroups, CancellationToken cancellationToken, out bool notifySelectedNewExpunge)\n\t\t{\n\t\t\tif (eventGroups == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (eventGroups));\n\n\t\t\tif (eventGroups.Count == 0)\n\t\t\t\tthrow new ArgumentException (\"No event groups specified.\", nameof (eventGroups));\n\n\t\t\tCheckDisposed ();\n\t\t\tCheckConnected ();\n\t\t\tCheckAuthenticated ();\n\n\t\t\tif ((engine.Capabilities & ImapCapabilities.Notify) == 0)\n\t\t\t\tthrow new NotSupportedException (\"The IMAP server does not support the NOTIFY extension.\");\n\n\t\t\tnotifySelectedNewExpunge = false;\n\n\t\t\tvar command = new StringBuilder (\"NOTIFY SET\");\n\t\t\tvar args = new List<object> ();\n\n\t\t\tif (status)\n\t\t\t\tcommand.Append (\" STATUS\");\n\n\t\t\tforeach (var group in eventGroups) {\n\t\t\t\tcommand.Append (' ');","sourceCodeStart":2000,"sourceCodeEnd":2036,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapClient.cs#L2000-L2036","documentation":"QueueNotifyCommand throws ArgumentException when the eventGroups list is null or empty (message covers the empty case). NOTIFY SET requires at least one ImapEventGroup describing what events to be notified about.","triggerScenarios":"Calling SetNotifyAsync / SetNotify with an empty List<ImapEventGroup> or a collection filtered down to zero entries; passing a null group list.","commonSituations":"Building event groups dynamically from user preferences where all options were disabled, yielding an empty list; default-initialized list never populated.","solutions":["Pass at least one ImapEventGroup, e.g. with ImapEventGroup.Selected for mailbox events","Guard with `if (groups.Count > 0)` before calling the API","Use ResetNotifyAsync (NOTIFY NONE) if the intent is to clear notifications instead of setting none"],"exampleFix":"// before\nawait client.SetNotifyAsync(new List<ImapEventGroup>(), token);\n// after\nvar groups = new List<ImapEventGroup> { ImapEventGroup.Selected };\nif (groups.Count > 0)\n    await client.SetNotifyAsync(groups, token);","handlingStrategy":"validation","validationCode":"if (eventGroups == null || eventGroups.Count == 0)\n    return; // nothing to set; skip or use ResetNotifyAsync","typeGuard":null,"tryCatchPattern":"try { await client.SetNotifyAsync(groups, token); }\ncatch (ArgumentException) { /* empty groups - skip or reset instead */ }","preventionTips":["Validate dynamic group-building code never yields an empty list","Use ResetNotifyAsync to clear notifications, not an empty set","Include a default ImapEventGroup (e.g. Selected) as a baseline"],"tags":["imap","notify","argument","mailkit"],"backgroundTag":"empty-required-field","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"}