Skip to content

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

Open
egouilliard-leyton wants to merge 12 commits into
MemTensor:dev-20260604-v2.0.19from
egouilliard-leyton:fix/share-cube-with-user-args
Open

Fix swapped args in share_cube_with_user → _validate_cube_access (fixes #1901)#1902
egouilliard-leyton wants to merge 12 commits into
MemTensor:dev-20260604-v2.0.19from
egouilliard-leyton:fix/share-cube-with-user-args

Conversation

@egouilliard-leyton

Copy link
Copy Markdown

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.
  • 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.

hijzy and others added 12 commits May 25, 2026 15:02
## Summary
- add an OpenClaw runtime lock to block duplicate plugin instances
before tools/hooks register
- fail startup on viewer port conflicts and clean up partial runtime
state
- keep lightweight local memories searchable/listable without an LLM
final filter, while preserving full-mode self-evolution boundaries
- cover runtime locking, duplicate startup, lightweight retrieval,
delayed agent_end recovery, and partial migration behavior

## Tests
- npm test -- --run tests/unit
- npm run lint
- npm run build
- git diff --check --cached
MemTensor#1807)

Automated PR from mem-agent-0520-niu to mem-agent-0520.
…r#1762)

* docs: translate openai_memory_locomo_eval_guide to Chinese

* docs: translate evaluation overview to Chinese
…emTensor#1793)

* fix(mcp): handle empty filter dict in search_memories tool

MCP clients such as Cherry Studio always pass filter:{} in conversation
mode. FastMCP rejects unknown or invalid parameters, returning HTTP 400
"Invalid request parameters". Accept the filter parameter and normalise
an empty dict to None so the call succeeds.

Fixes MemTensor#1718

* docs: translate core API reference docs to English (MemTensor#1693)

* fix: resolve ruff lint/format issues in test_mcp_serve.py
* fix(mcp): handle empty filter dict in search_memories tool

MCP clients such as Cherry Studio always pass filter:{} in conversation
mode. FastMCP rejects unknown or invalid parameters, returning HTTP 400
"Invalid request parameters". Accept the filter parameter and normalise
an empty dict to None so the call succeeds.

Fixes MemTensor#1718

* docs: translate module docs to Chinese (MemTensor#1691)

* fix: resolve ruff lint/format issues in test_mcp_serve.py

---------

Co-authored-by: Jiang <33757498+hijzy@users.noreply.github.com>
## Description

Please include a summary of the change, the problem it solves, the
implementation approach, and relevant context. List any dependencies
required for this change.

Related Issue (Required):  Fixes #issue_number

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Refactor (does not change functionality, e.g. code style
improvements, linting)
- [ ] Documentation update

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration

- [ ] Unit Test
- [ ] Test Script Or Test Steps (please provide)
- [ ] Pipeline Automated API Test (please provide)

## Checklist

- [ ] I have performed a self-review of my own code | 我已自行检查了自己的代码
- [ ] I have commented my code in hard-to-understand areas |
我已在难以理解的地方对代码进行了注释
- [ ] I have added tests that prove my fix is effective or that my
feature works | 我已添加测试以证明我的修复有效或功能正常
- [ ] I have created related documentation issue/PR in
[MemOS-Docs](https://github.com/MemTensor/MemOS-Docs) (if applicable) |
我已在 [MemOS-Docs](https://github.com/MemTensor/MemOS-Docs) 中创建了相关的文档
issue/PR(如果适用)
- [ ] I have linked the issue to this PR (if applicable) | 我已将 issue
链接到此 PR(如果适用)
- [ ] I have mentioned the person who will review this PR | 我已提及将审查此 PR
的人

## Reviewer Checklist
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number)
- [ ] Made sure Checks passed
- [ ] Tests have been provided
## Description

Please include a summary of the change, the problem it solves, the
implementation approach, and relevant context. List any dependencies
required for this change.

Related Issue (Required):  Fixes #issue_number

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Refactor (does not change functionality, e.g. code style
improvements, linting)
- [ ] Documentation update

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration

- [ ] Unit Test
- [ ] Test Script Or Test Steps (please provide)
- [ ] Pipeline Automated API Test (please provide)

## Checklist

- [ ] I have performed a self-review of my own code | 我已自行检查了自己的代码
- [ ] I have commented my code in hard-to-understand areas |
我已在难以理解的地方对代码进行了注释
- [ ] I have added tests that prove my fix is effective or that my
feature works | 我已添加测试以证明我的修复有效或功能正常
- [ ] I have created related documentation issue/PR in
[MemOS-Docs](https://github.com/MemTensor/MemOS-Docs) (if applicable) |
我已在 [MemOS-Docs](https://github.com/MemTensor/MemOS-Docs) 中创建了相关的文档
issue/PR(如果适用)
- [ ] I have linked the issue to this PR (if applicable) | 我已将 issue
链接到此 PR(如果适用)
- [ ] I have mentioned the person who will review this PR | 我已提及将审查此 PR
的人

## Reviewer Checklist
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number)
- [ ] Made sure Checks passed
- [ ] Tests have been provided
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
@Memtensor-AI Memtensor-AI changed the base branch from main to dev-20260604-v2.0.19 June 10, 2026 15:43
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.

share_cube_with_user passes swapped args to _validate_cube_access — fails for every well-formed call

6 participants