{"record":{"id":"9f2b9deb3e615c5e","repo":"bitwarden/server","slug":"you-cannot-add-yourself-to-a-collection","errorCode":null,"errorMessage":"You cannot add yourself to a collection.","messagePattern":"You cannot add yourself to a collection\\.","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"src/Api/AdminConsole/Controllers/OrganizationUsersController.cs","lineNumber":482,"sourceCode":"            collectionAccessToSave, groupsToSave, model.DefaultUserCollectionName);\n\n        return TypedResults.Ok();\n    }\n\n    /// <summary>\n    /// Resolves the collection access to persist for an organization user update, enforcing the saving user's\n    /// authorization over the affected collections.\n    /// </summary>\n    private async Task<List<CollectionAccessSelection>> GetAuthorizedCollectionsToSaveAsync(OrganizationUserUpdateRequestModel model, ICollection<CollectionAccessSelection> currentAccess, bool editingSelf, Organization organization)\n    {\n        // A self-editing user can't add themselves to collections they don't already have access to,\n        // unless admins can access all collections.\n        var currentAccessIds = currentAccess.Select(c => c.Id).ToHashSet();\n        if (editingSelf &&\n            !organization.AllowAdminAccessToAllCollectionItems &&\n            model.Collections.Any(c => !currentAccessIds.Contains(c.Id)))\n        {\n            throw new BadRequestException(\"You cannot add yourself to a collection.\");\n        }\n\n        // Authorization check:\n        // You must have authorization to ModifyUserAccess for all collections being saved.\n        var postedCollections = await _collectionRepository.GetManyByManyIdsAsync(model.Collections.Select(c => c.Id));\n        if (postedCollections.Count != 0 &&\n            !(await _authorizationService.AuthorizeAsync(User, postedCollections, BulkCollectionOperations.ModifyUserAccess)).Succeeded)\n        {\n            throw new NotFoundException();\n        }\n\n        // Preserve the target's current collections the saving user can't edit, so they aren't overwritten.\n        var currentCollections = await _collectionRepository.GetManyByManyIdsAsync(currentAccess.Select(cas => cas.Id));\n\n        var readonlyCollectionIds = new HashSet<Guid>();\n\n        foreach (var collection in currentCollections)\n        {","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs#L464-L500","documentation":"Error \"You cannot add yourself to a collection.\" thrown in bitwarden/server.","triggerScenarios":"Thrown when an organization user attempts to add themselves to a collection via the user-collection assignment endpoint, which is disallowed; another admin must perform the assignment.","commonSituations":"See trigger scenarios.","solutions":["Have another owner or admin add you to the collection instead of adding yourself.","Assign the collection to a group you belong to and manage membership through the group."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}