fix(vfolder): fallback system role creation on invitation acceptance#11886
Open
wali-reheman wants to merge 1 commit into
Open
fix(vfolder): fallback system role creation on invitation acceptance#11886wali-reheman wants to merge 1 commit into
wali-reheman wants to merge 1 commit into
Conversation
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).
|
|
HyeockJinKim
requested changes
Jun 1, 2026
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 |
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.