Skip to content

[BUG] edit_note resolves nonexistent identifiers to nearest match via fuzzy search #649

@Brennall

Description

@Brennall

edit_note resolves nonexistent identifiers to nearest match via fuzzy search

Summary

edit_note uses non-strict entity resolution, which means a misspelled or nonexistent identifier silently resolves to the nearest matching note and edits it. This is a data loss risk — destructive edit operations should fail on unresolved identifiers, not fuzzy-match to a different note.

Reproduction

  1. Create two notes:
write_note(title="Routing Test A", content="# A\n\nContent A.\n\n## Observations\n\n- [test] Note A\n\n## Relations", directory="test", project="aurora")
write_note(title="Routing Test B", content="# B\n\nContent B.\n\n## Observations\n\n- [test] Note B\n\n## Relations", directory="test", project="aurora")
  1. Edit a note that does not exist:
edit_note(identifier="Routing Test NONEXISTENT", operation="append", content="\n- THIS SHOULD FAIL", project="aurora")
  1. Expected: Error — note not found.
  2. Actual: The edit silently lands on Routing Test B (nearest fuzzy match). No error. No indication the wrong note was edited.

Root Cause

In mcp/tools/edit_note.py, the resolve call does not pass strict=True:

entity_id = await knowledge_client.resolve_entity(identifier)

The KnowledgeClient.resolve_entity method supports a strict parameter that disables fuzzy fallback, but edit_note doesn't use it. The resolution chain falls through to fuzzy/vector search, which returns the nearest match rather than failing.

Suggested Fix

entity_id = await knowledge_client.resolve_entity(identifier, strict=True)

One line change. The edit_note docstring already states "Must be an exact match — fuzzy matching is not supported for edit operations" — the code should match the documented behaviour.

Impact

This has caused real data loss in production use. A note edit targeting a nonexistent identifier silently overwrote unrelated content in a different note. The user did not discover the damage until later inspection.

The risk is highest when:

  • A note has been deleted or moved but an edit targets the old identifier
  • An AI assistant misspells an identifier during an automated edit
  • append or prepend operations are used (these auto-create on not-found, but only after fuzzy resolution fails — if fuzzy resolution succeeds against the wrong note, the auto-create path is never reached)

Environment

  • Basic Memory v0.19.0 (also present in v0.18.5)
  • Windows, installed via uv tool install
  • Reproduced via Claude Desktop MCP integration

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions