{"record":{"id":"53f14c5e4df38ad0","repo":"jstedfast/MailKit","slug":"no-rights-were-specified-parameter-rights","errorCode":null,"errorMessage":"No rights were specified. (Parameter 'rights')","messagePattern":"No rights were specified\\. \\(Parameter 'rights'\\)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapFolder.cs","lineNumber":2746,"sourceCode":"\t\tpublic override async Task<AccessRights> GetMyAccessRightsAsync (CancellationToken cancellationToken = default)\n\t\t{\n\t\t\tvar ic = QueueGetMyAccessRightsCommand (cancellationToken);\n\n\t\t\tawait Engine.RunAsync (ic).ConfigureAwait (false);\n\n\t\t\treturn ProcessGetMyAccessRightsResponse (ic);\n\t\t}\n\n\t\tImapCommand QueueModifyAccessRightsCommand (string name, string action, AccessRights rights, CancellationToken cancellationToken)\n\t\t{\n\t\t\tif (name == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (name));\n\n\t\t\tif (rights == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (rights));\n\n\t\t\tif (action.Length != 0 && rights.Count == 0)\n\t\t\t\tthrow new ArgumentException (\"No rights were specified.\", nameof (rights));\n\n\t\t\tif ((Engine.Capabilities & ImapCapabilities.Acl) == 0)\n\t\t\t\tthrow new NotSupportedException (\"The IMAP server does not support the ACL extension.\");\n\n\t\t\tCheckState (false, false);\n\n\t\t\treturn Engine.QueueCommand (cancellationToken, null, \"SETACL %F %S %S\\r\\n\", this, name, action + rights);\n\t\t}\n\n\t\tvoid ProcessModifyAccessRightsResponse (ImapCommand ic)\n\t\t{\n\t\t\tProcessResponseCodes (ic, null);\n\n\t\t\tic.ThrowIfNotOk (\"SETACL\");\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Add access rights for the specified identity.","sourceCodeStart":2728,"sourceCodeEnd":2764,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapFolder.cs#L2728-L2764","documentation":"ArgumentException 'No rights were specified' because the caller asked to add or remove rights but supplied an empty AccessRights collection while the action string is non-empty. An ACL STORE with no rights makes no sense, so MailKit rejects it up front.","triggerScenarios":"Calling folder.AddAccessRightsAsync(name, new AccessRights()) or RemoveAccessRightsAsync with an AccessRights whose Count == 0; action (e.g. \"+\" or \"-\") is non-empty so the `action.Length != 0 && rights.Count == 0` guard throws.","commonSituations":"Computing the diff between current and desired ACL and it came out empty (nothing to change); parsing a rights string that was empty; logic bug producing an empty right list.","solutions":["Skip the call entirely when the rights diff is empty instead of calling with an empty collection","Pass at least one right character, e.g. new AccessRights(\"w\"), for add/remove operations","Use SetAccessRightsAsync when you intend to replace the full set (it uses a different action)","Fix the diff computation that yielded zero rights"],"exampleFix":"// before\nvar delta = ComputeRightsDiff(current, desired);\nawait folder.AddAccessRightsAsync(\"jane\", delta); // delta.Count == 0\n// after\nvar delta = ComputeRightsDiff(current, desired);\nif (delta.Count > 0)\n    await folder.AddAccessRightsAsync(\"jane\", delta);","handlingStrategy":"validation","validationCode":"if (rights == null || rights.Count == 0)\n    return; // nothing to change — skip the ACL command","typeGuard":"bool HasRights(AccessRights r) => r is { Count: > 0 };","tryCatchPattern":"try {\n    await folder.AddAccessRightsAsync(identity, rights);\n} catch (ArgumentException ex) when (ex.ParamName == \"rights\") {\n    logger.LogWarning(ex, \"No rights to apply for {Identity}; skipping\", identity);\n}","preventionTips":["No-op when the computed rights delta is empty instead of issuing a command","Unit-test your rights-diff logic with empty-diff cases","Distinguish 'no change' from an error condition in your ACL sync code","Use SetAccessRightsAsync only when you intend to replace the whole set"],"tags":["imap","acl","empty-argument","access-rights"],"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-23T08:17:48.524Z"}