-
Notifications
You must be signed in to change notification settings - Fork 175
Description
Title: edit_note and delete_note missing detect_project_from_url_prefix — incorrect cloud routing
Bug Description
edit_note and delete_note are missing the detect_project_from_url_prefix() call that read_note, build_context, search_notes, and read_content all have. This causes incorrect routing (potentially to cloud instead of local) when project=None is passed and no default_project is configured.
Version
basic-memory v0.20.2
Steps to Reproduce
- Configure basic-memory with multiple projects but no
default_projectset - Call
edit_note(identifier="memory://myproject/some-note", operation="append", content="test")without explicitprojectparam - Observe that routing falls through to
resolve_project_parameter(None)→ cloud API discovery
Expected Behavior
edit_note should detect the project from the memory:// URL prefix (like read_note does) and route locally.
Root Cause
In read_note.py (lines 136-140), before calling get_project_client():
if project is None:
detected = detect_project_from_url_prefix(identifier, ConfigManager().config)
if detected:
project = detectedThis pattern exists in:
- ✅
read_note.py(line 136) - ✅
build_context.py(line 189) - ✅
search.py(line 522) - ✅
read_content.py(line 215)
But is missing from:
- ❌
edit_note.py(line 258 goes directly toget_project_client(project, ...)) - ❌
delete_note.py(line 225 goes directly toget_project_client(project, ...))
Note: write_note is not affected because it takes title and directory as separate params rather than an identifier that could contain a memory:// URL prefix.
Suggested Fix
For edit_note.py and delete_note.py, add the missing imports:
from basic_memory.config import ConfigManager
from basic_memory.mcp.project_context import detect_project_from_url_prefixAnd add before async with get_project_client(...):
if project is None:
detected = detect_project_from_url_prefix(identifier, ConfigManager().config)
if detected:
project = detectedThis is identical to the pattern in read_note.py.
Impact
- Users with
default_projectset in config are partially shielded (the default catches theNone) - Users without
default_projector with multi-project setups relying on URL-prefix routing will hit cloud API discovery failures or incorrect routing - The inconsistency between read-path tools (fixed) and write-path tools (missing) is confusing