{"record":{"id":"b84bf14e1f4e48b6","repo":"microsoft/garnet","slug":"the-special-default-user-cannot-be-removed-from","errorCode":null,"errorMessage":"The special 'default' user cannot be removed from the system","messagePattern":"The special 'default' user cannot be removed from the system","errorType":"exception","errorClass":"ACLException","httpStatus":null,"severity":"error","filePath":"libs/server/ACL/AccessControlList.cs","lineNumber":101,"sourceCode":"\n            // If a user with the given name already exists in the ACL, the new user cannot be added\n            if (!_userHandles.TryAdd(username, userHandle))\n            {\n                throw new ACLUserAlreadyExistsException(username);\n            }\n        }\n\n        /// <summary>\n        /// Deletes the <see cref=\"UserHandle\"/> associated with the given username.\n        /// </summary>\n        /// <param name=\"username\">Username of the user to delete.</param>\n        /// <returns>true if successful, false if no matching user was found.</returns>\n        /// <exception cref=\"ACLException\">Thrown if the given user exists but cannot be deleted.</exception>\n        public bool DeleteUserHandle(string username)\n        {\n            if (username == DefaultUserName)\n            {\n                throw new ACLException(\"The special 'default' user cannot be removed from the system\");\n            }\n            return _userHandles.TryRemove(username, out _);\n        }\n\n        /// <summary>\n        /// Remove all <see cref=\"UserHandle\"/>s from the list.\n        /// </summary>\n        public void ClearUsers()\n        {\n            _userHandles.Clear();\n        }\n\n        /// <summary>\n        /// Return a list of all usernames and user objects.\n        /// </summary>\n        /// <returns>Dictionary of username/user pairs.</returns>\n        public IReadOnlyDictionary<string, UserHandle> GetUserHandles()\n        {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/ACL/AccessControlList.cs#L83-L119","documentation":"Thrown by AccessControlList.DeleteUserHandle when the username equals the constant 'default'. The default user is a protected, always-present account that grants bootstrap access, so it cannot be removed. Deletion of any other (non-existent) username simply returns false; only 'default' throws.","triggerScenarios":"Calling DeleteUserHandle(\"default\") explicitly, or an ACL management command (ACL DELUSER default) reaching this path. The comparison is case-sensitive against the literal 'default', so 'Default' would not throw (it would return false as not-found).","commonSituations":"A script that iterates all usernames and deletes them; a UI/CLI that offers delete on the default user; importing rules that attempt to redefine-then-delete default.","solutions":["Skip 'default' in any bulk-delete loop.","Disable the default user (set it off / change its password) instead of deleting it if you need to restrict bootstrap access.","Guard with a case-sensitive check username != \"default\" before calling DeleteUserHandle.","Catch ACLException at the call site if deletion is best-effort."],"exampleFix":"// before\nacl.DeleteUserHandle(username);\n\n// after\nif (!string.Equals(username, \"default\", StringComparison.Ordinal))\n    acl.DeleteUserHandle(username);","handlingStrategy":"validation","validationCode":"if (string.Equals(username, \"default\", StringComparison.Ordinal))\n    throw new InvalidOperationException(\"The 'default' user cannot be deleted.\");","typeGuard":"static bool IsDeletable(string username) => !string.Equals(username, \"default\", StringComparison.Ordinal);","tryCatchPattern":"try { acl.DeleteUserHandle(username); }\ncatch (ACLException ex) when (ex.Message.Contains(\"default\")) { /* skip protected default user */ }","preventionTips":["Exclude 'default' from bulk-delete loops.","Disable/restrict the default user instead of deleting it.","Guard with a case-sensitive 'default' check."],"tags":["acl","user-management","default-user","protected-resource"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}