Skip to content

fix(vfolder): fallback system role creation on invitation acceptance#11886

Open
wali-reheman wants to merge 1 commit into
lablup:mainfrom
wali-reheman:fix/vfolder-invitation-fallback-system-role
Open

fix(vfolder): fallback system role creation on invitation acceptance#11886
wali-reheman wants to merge 1 commit into
lablup:mainfrom
wali-reheman:fix/vfolder-invitation-fallback-system-role

Conversation

@wali-reheman
Copy link
Copy Markdown

When accepting a vfolder invitation for a user without a SYSTEM role, the lookup now creates one as a fallback inside the transaction instead of failing with ObjectNotFound. This handles SSO-created accounts that may not have an RBAC role yet. Includes unit tests for both the existing-role path and the fallback-creation path.

When a user without a SYSTEM role accepts a vfolder invitation,
_get_user_role_id() now creates one as a fallback inside the existing
write transaction, instead of raising ObjectNotFound and rolling back.
This allows invitation acceptance to succeed for users (e.g. SSO-created
accounts) who may not yet have an RBAC system role.

Fixes backend.ai issue lablup#11885 (BA-6253).
@wali-reheman wali-reheman requested a review from a team as a code owner June 1, 2026 13:06
@cla-assistant
Copy link
Copy Markdown

cla-assistant Bot commented Jun 1, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Comment on lines 1150 to +1165
result = await session.scalar(stmt)
if result is None:
raise ObjectNotFound(object_name="user system role", extra_msg=str(user_id))
return result
if result is not None:
return result

# Fallback: create a system role for this user and return its id
spec = UserSystemRoleSpec(user_id=user_id)
role = await self._role_manager.create_system_role(session, spec)
return role.id
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach doesn't seem appropriate. It would make more sense for the operation to fail if it can't retrieve the data from get; creating and passing the user's role when it can't be retrieved is very tricky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants