Skip to content

get_default_cube_config crashes with UnboundLocalError on invalid text_mem_type #2441

Closed as not planned

Description

@simpleqt

Bug Description

get_default_cube_config in src/memos/mem_os/utils/default_config.py only assigns text_mem_config inside the tree_text and general_text branches, but there is no else. Any other value (e.g. a typo like "tree-text" passed through MOS_NEO4J_*/env config plumbing or the MCP create_cube path) crashes with a bare UnboundLocalError:

>>> get_default_cube_config(openai_api_key="sk-x", text_mem_type="tree-text")
UnboundLocalError: cannot access local variable 'text_mem_config' where it is not associated with a value

Expected Behavior

An invalid text_mem_type should raise a clear ValueError naming the accepted values.

Environment

MemOS main, python 3.14.

Additional Context

Fix + red/green-verified test ready; PR to follow referencing this issue.

Activity

  1. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    area:memcubeGeneralMemCube / cube 生命周期 / cube 配置
    status:in-progressSomeone or AI is working on it | 人工或 AI 正在处理
    types:bugSomething isn't working | 功能异常
    on Sep 30, 2026
  2. self-assigned this
    on Sep 30, 2026
  3. Memtensor-AI commented on Sep 30, 2026

    @Memtensor-AI
    Collaborator

    🤖 AutoDev has picked up this issue and started working on it.

    Task ID: eb1debf3e224d267
    Working branch: bugfix/autodev-2441-20260930135356599
    Target branch: latest dev* branch
    Workflow: opsp (analysis → coding → testing → PR)

    I will post the PR link here once done. If I need more information, I will ask in the comments.

  4. added a commit that references this issue on Sep 30, 2026
    dfdca2b
  5. Memtensor-AI commented on Sep 30, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task eb1debf3e224d267 completed.

    Summary: Fixes issue #2441: get_default_cube_config (and its sibling get_default_config) in src/memos/mem_os/utils/default_config.py no longer crashes with a bare UnboundLocalError when a caller passes an unsupported text_mem_type such as the reported "tree-text" typo. Both helpers now call a new _validate_text_mem_type guard at entry and raise a clear ValueError naming the offending value and the accepted set ("tree_text", "general_text"), so misconfigurations coming through the MOS_TEXT_MEM_TYPE env var or the MCP create_cube path fail loudly with an actionable message. As a defence-in-depth, get_default_cube_config's if/elif chain gained an explicit else branch that re-raises the same ValueError, so a future refactor cannot silently reintroduce the fall-through.

    Added tests/mem_os/utils/test_default_config.py with five cases covering the reported reproducer ("tree-text"), other unknown backends, empty strings, symmetric behavior on get_default_config, and a happy-path smoke test for "general_text". All new tests pass; the full tests/mem_os/ suite (41 tests) continues to pass; ruff check and ruff format are clean on the touched files. No public API, schema, or OpenAPI contract changes; no new dependencies.

    Base branch: main
    Branch: bugfix/autodev-2441-20260930135356599
    Commit: dfdca2b
    PR: #2445
    Assigned to: @syzsunshine219
    Reviewers: @WeiminLee

  6. added
    ai:testingAI agent is running tests | AI 正在运行测试
    and removed
    ai:codingAI agent is coding | AI 正在编码
    on Sep 30, 2026
  7. added
    ai:pr-readyAI-created PR is ready for review | AI 生成的 PR 已等待评审
    and removed
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Sep 30, 2026
  8. github-actions commented on Nov 5, 2026

    @github-actions
    Contributor

    This issue has been automatically marked as stale due to inactivity.

  9. added
    status:staleAuto-marked stale after 30d inactivity; closes 7d later unless exempt.
    on Nov 5, 2026
  10. github-actions commented on Nov 14, 2026

    @github-actions
    Contributor

    This issue has been automatically closed due to inactivity.

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

Metadata

Metadata

Labels

ai:pr-readyAI-created PR is ready for review | AI 生成的 PR 已等待评审area:memcubeGeneralMemCube / cube 生命周期 / cube 配置status:in-progressSomeone or AI is working on it | 人工或 AI 正在处理status:staleAuto-marked stale after 30d inactivity; closes 7d later unless exempt.types:bugSomething isn't working | 功能异常

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions