Accepting a VFolder invitation fails when the invitee already holds the granted RBAC permission
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 368
Description
### Symptom
Accepting a VFolder invitation can fail with an internal server error (HTTP 500). The manager raises a database unique-constraint violation on the permissions table (uq_permissions_role_scope_entity_op) while granting RBAC permissions to the invitee.
### Code flow
REST accept_invitation handler -> VFolderInviteService.accept_invitation -> VFolderRepository.create_vfolder_permission -> execute_rbac_granter (repositories/base/rbac/granter.py).
In execute_rbac_granter the ref-edge insert into association_scopes_entities is idempotent (ON CONFLICT DO NOTHING), but the subsequent insert into the permissions table is a plain ORM add_all/flush with no conflict handling. When the invitee role already holds the same (role_id, scope_type, scope_id, entity_type, operation) tuple on that VFolder, the flush violates the unique constraint and surfaces as a 500.
### Reproduction
Invite a user to a VFolder and accept the invitation when that user role already has the corresponding permission on the same VFolder (for example a repeated invite/accept, or a previously granted overlapping operation).
JIRA Issue: BA-6460
Contributor guide
Assessment
This issue has not been assessed yet.