Skip to content

[BUG] #664

@wayanwolvie

Description

@wayanwolvie

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

  1. Configure basic-memory with multiple projects but no default_project set
  2. Call edit_note(identifier="memory://myproject/some-note", operation="append", content="test") without explicit project param
  3. 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 = detected

This 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 to get_project_client(project, ...))
  • delete_note.py (line 225 goes directly to get_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_prefix

And add before async with get_project_client(...):

if project is None:
    detected = detect_project_from_url_prefix(identifier, ConfigManager().config)
    if detected:
        project = detected

This is identical to the pattern in read_note.py.

Impact

  • Users with default_project set in config are partially shielded (the default catches the None)
  • Users without default_project or 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions