jstedfast/MailKit · error · ArgumentException
No event groups specified.
Error message
No event groups specified.
What it means
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.
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
Example fix
// before
await client.SetNotifyAsync(new List<ImapEventGroup>(), token);
// after
var groups = new List<ImapEventGroup> { ImapEventGroup.Selected };
if (groups.Count > 0)
await client.SetNotifyAsync(groups, token); Defensive patterns
Strategy: validation
Validate before calling
if (eventGroups == null || eventGroups.Count == 0)
return; // nothing to set; skip or use ResetNotifyAsync Try / catch
try { await client.SetNotifyAsync(groups, token); }
catch (ArgumentException) { /* empty groups - skip or reset instead */ } Prevention
- 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
When it happens
Trigger: Calling SetNotifyAsync / SetNotify with an empty List<ImapEventGroup> or a collection filtered down to zero entries; passing a null group list.
Common situations: Building event groups dynamically from user preferences where all options were disabled, yielding an empty list; default-initialized list never populated.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- The host name cannot be empty.
- The socket is not connected.
- The doneToken must be cancellable.
- The IMAP server does not support the NOTIFY extension.
- Value cannot be null. (Parameter 'name')
AI-assisted analysis of jstedfast/MailKit@9d3859a785 (2026-09-15).
Data as JSON: /api/errors/14761580e2853d2c.
Report an issue: GitHub.
Appendix: source
Thrown at MailKit/Net/Imap/ImapClient.cs:2018
if (doneToken.IsCancellationRequested)
return;
using (var context = new ImapIdleContext (engine, doneToken, cancellationToken)) {
var ic = QueueIdleCommand (context, cancellationToken);
engine.Run (ic);
ProcessIdleResponse (ic);
}
}
ImapCommand QueueNotifyCommand (bool status, IList<ImapEventGroup> eventGroups, CancellationToken cancellationToken, out bool notifySelectedNewExpunge)
{
if (eventGroups == null)
throw new ArgumentNullException (nameof (eventGroups));
if (eventGroups.Count == 0)
throw new ArgumentException ("No event groups specified.", nameof (eventGroups));
CheckDisposed ();
CheckConnected ();
CheckAuthenticated ();
if ((engine.Capabilities & ImapCapabilities.Notify) == 0)
throw new NotSupportedException ("The IMAP server does not support the NOTIFY extension.");
notifySelectedNewExpunge = false;
var command = new StringBuilder ("NOTIFY SET");
var args = new List<object> ();
if (status)
command.Append (" STATUS");
foreach (var group in eventGroups) {
command.Append (' ');View on GitHub (pinned to 9d3859a785)