MemOS icon indicating copy to clipboard operation
MemOS copied to clipboard

Fix swapped args in share_cube_with_user → _validate_cube_access (fixes #1901)

Open egouilliard-leyton opened this issue 5 months ago • 0 comments

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(cube_id, target_user_id)
  • 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

  • [ ] Add a `test_share_cube_with_user_success` unit test: owner creates a cube, adds a memory, shares with target, target's `search()` then returns the memory. (I can push this in a follow-up commit if a maintainer requests — the existing test layout in the repo would dictate the right location.)
  • [ ] Add a `test_share_cube_with_user_denies_non_owner`: a user who does not own/have access to the cube cannot share it.
  • [x] Manual repro of the bug exists in the linked issue; the fix makes that repro pass.

Notes

  • Reproduces deterministically on `b60616d` (HEAD of `main`, v2.0.18-dev) and `MemoryOS==2.0.17` on PyPI.
  • I have not added a regression test in this PR because I wasn't sure which test directory layout the project prefers for `MOSCore` API tests. Happy to add one in a follow-up commit if a maintainer points to the right place.

egouilliard-leyton avatar Jun 08 '26 17:06 egouilliard-leyton