Fix swapped args in share_cube_with_user → _validate_cube_access (fixes #1901)#1902
Open
egouilliard-leyton wants to merge 2 commits into
Open
Fix swapped args in share_cube_with_user → _validate_cube_access (fixes #1901)#1902egouilliard-leyton wants to merge 2 commits into
egouilliard-leyton wants to merge 2 commits into
Conversation
share_cube_with_user(cube_id, target_user_id) passed args to
_validate_cube_access(user_id, cube_id) in the wrong order, raising
"User '<cube_id>' does not exist" for every well-formed call.
Per the in-code comment ("Validate current user has access to this
cube"), the validation should check the *current* (sharing) user
has access -- not the target -- so the fix uses self.user_id instead
of target_user_id. The target's existence is already validated on
the next line via user_manager.validate_user(target_user_id).
Fixes MemTensor#1901
Collaborator
|
Cloud AutoDev retest on dev-v2.0.22: NO EFFECTIVE DIFF. Run: tr-f3d0be52-94d on test-engine-v3. Recommendation: treat this PR as superseded/no-op rather than merge it. |
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.
Summary
Fixes #1901.
`MOSCore.share_cube_with_user(cube_id, target_user_id)` is currently unusable: every well-formed call raises `ValueError("User '<cube_id>' does not exist or is inactive")` because the args passed to `_validate_cube_access` are in the wrong order.
This one-line fix passes the current user (`self.user_id`) plus the `cube_id`, matching both the validator's signature `_validate_cube_access(self, user_id, cube_id)` and the in-code comment immediately above the call ("Validate current user has access to this cube"). The target user's existence is already validated on the next line.
Diff
```diff
def share_cube_with_user(self, cube_id: str, target_user_id: str) -> bool:
...
# Validate current user has access to this cube
self._validate_cube_access(self.user_id, cube_id)
Validate target user exists
if not self.user_manager.validate_user(target_user_id):
raise ValueError(...)
return self.user_manager.add_user_to_cube(target_user_id, cube_id)
```
Test plan
Notes