Skip to content

get_default_cube_config: clear ValueError instead of UnboundLocalError for invalid text_mem_type - #2442

Open
simpleqt wants to merge 1 commit into
MemTensor:mainfrom
simpleqt:sq/default-config-textmem-type
Open

simpleqt wants to merge 1 commit into
MemTensor:mainfrom
simpleqt:sq/default-config-textmem-type

Conversation

@simpleqt

Copy link
Copy Markdown

Fixes #2441

Summary

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, with no else. Any other value — e.g. a typo like "tree-text" reaching the config plumbing — 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

Fix

Add the missing else branch raising a clear error that names the accepted values:

ValueError: text_mem_type must be 'tree_text' or 'general_text', got 'tree-text'

Regression test

Added tests/mem_os/test_default_config_text_mem_type.py:

  • red/green verified: the invalid-type cases fail against the old implementation (UnboundLocalError) and pass with the fix
  • parametrized over several invalid spellings, and pins that both valid types still build a cube config

ruff check (repo-pinned 0.11.8) passes on both touched files.

AI Disclosure

  • Tool(s): Claude (ZCode CLI)
  • Used for: debugging assistance, code suggestions, and drafting this PR description. All changes human-reviewed.

get_default_cube_config only assigned text_mem_config inside the
tree_text/general_text branches, so any other value crashed with a
bare UnboundLocalError.

Fixes MemTensor#2441
Copilot AI balanced review requested due to automatic review settings September 30, 2026 14:01
@Memtensor-AI Memtensor-AI added area:core MOS 编排层 / 框架底座 / 跨模块问题 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Sep 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

🤖 Open Code Review

Target: PR #2442
Task: a63e2db40c11703c
Base: main
Head: sq/default-config-textmem-type

✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s).

Generated by cloud-assistant via Open Code Review.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

✅ Automated Test Results: PASSED

All tests passed (5/5 executed). memos_python_core/changed-repo-python: 5/5. Duration: 8s [advisory, non-gating] AI-generated tests on branch test/auto-gen-a63e2db40c11703c-20260930220428: 44/44 passed — these do NOT affect the PR verdict; review the branch manually.

Branch: sq/default-config-textmem-type

@Memtensor-AI Memtensor-AI added status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发 and removed status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core MOS 编排层 / 框架底座 / 跨模块问题 status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_default_cube_config crashes with UnboundLocalError on invalid text_mem_type

4 participants