Skip to content

[BUG] edit_note with append creates a duplicate project-named directory when a missing note is addressed by a project-prefixed identifier (fix with patch included) #1775

Closed

Description

@misejoh

Bug Description

On Basic Memory 0.23.2, edit_note(operation="append") creates a missing note at an unexpected path when its identifier includes the project prefix. That prefix becomes an extra directory below the selected project's root.

Appending to an existing note through a project-qualified memory URL resolves to the expected file instead. This appears to be an inconsistency between resolving existing notes and creating missing ones; the implementation has not been inspected.

The examples below are anonymized mappings of observed calls and responses, not a new reproduction with these exact placeholder names.

Steps To Reproduce

Use a disposable project/environment. Calls that create notes have side effects; remove only the resulting test files afterwards.

For this example, assume a default project named demo and a project-relative directory scratch/repro. All calls below use operation="append", content="Disposable reproduction note." and output_format="json". The four initial targets are absent before the corresponding calls.

# identifier project argument Observed response Observed project-relative file_path
1 scratch/repro/note-a demo Created; fileCreated: true scratch/repro/note-a.md
2 memory://scratch/repro/note-b demo UNRESOLVED_PROJECT_ROUTE; projectRoute: "scratch"; no note created —
3 demo/scratch/repro/note-c demo Created; fileCreated: true demo/scratch/repro/note-c.md
4 demo/scratch/repro/note-d omitted Created; fileCreated: true demo/scratch/repro/note-d.md
5 memory://demo/scratch/repro/note-a demo Edited existing note from #1; fileCreated: false scratch/repro/note-a.md

Example arguments for #3:

{
  "identifier": "demo/scratch/repro/note-c",
  "project": "demo",
  "operation": "append",
  "content": "Disposable reproduction note.",
  "output_format": "json"
}

Response shape observed for #3, with identifying values replaced:

{
  "title": "note-c",
  "permalink": "demo/scratch/repro/note-c",
  "file_path": "demo/scratch/repro/note-c.md",
  "checksum": null,
  "operation": "append",
  "fileCreated": true
}

An earlier call targeting a different missing note through memory://demo/scratch/repro/note-missing, with the project selected, also created a file under the extra demo/ directory.

The unexpected files were checked on disk as well as through tool responses: the extra project-named directory really existed beneath the project root. It was not just a display issue. For an illustrative root <project-root>, the actual location was <project-root>/demo/scratch/repro/..., not <project-root>/scratch/repro/....

Expected Behavior

A project-qualified identifier accepted for an existing note should have consistent semantics when append creates a missing note. Either create the note at the corresponding project-relative path without duplicating the project segment, or reject ambiguous/unsupported creation identifiers explicitly.

For #3 and #4, the intended project-relative paths were scratch/repro/note-c.md and scratch/repro/note-d.md.

Actual Behavior

  • Missing notes addressed with a project prefix create files under an additional project-named directory.
  • Existing note Pre release fixups #5 resolves to its normal path.
  • Including versus omitting the project argument did not prevent the duplicate-directory outcome in the tested calls (fix: fix permalink uniqueness violations on create/update/sync #3 and Create/update db on startup  #4). This does not establish behavior for every project-selection scenario.
  • prepend was not tested; this report concerns append only.
  • The exact internal cause is unverified. The observed file paths suggest that creation treats the project prefix differently from existing-note resolution.

Environment

  • OS: Ubuntu 22.04
  • Python version: 3.14
  • Basic Memory version: 0.23.2, self-hosted.
  • Installation method: Pip and git clone

Additional Context

  • Transport: MCP over Streamable HTTP.
  • Client: Hermes Agent.
  • permalinks_include_project: true, verified in the server configuration.
  • Two projects are configured. The tested project is the default; it is called demo in this report. Other project names are omitted.
  • Latest-release reproduction: not performed.

Impact

Reusing a project-qualified identifier for a note that does not yet exist (for example, a new monthly log) can silently create an unexpected directory tree. Existing-note tests can succeed and therefore fail to reveal this creation-path behavior.

Secondary routing observation

Call #2 treats scratch as a project route and returns UNRESOLVED_PROJECT_ROUTE despite an explicit project argument. Included for completeness, not asserted to be a separate bug: the intended semantics of this unqualified memory URL have not been established here.

Workaround

  • For deliberate creation, use write_note with an explicit project-relative directory.
  • In these tests, appending with a plain project-relative identifier (scratch/repro/...) avoided the extra directory.
  • When editing only, verify existence first and inspect fileCreated and file_path in the JSON response. A pre-check alone is not an atomic guarantee that the note still exists at edit time.

Possible Solution

Please check whether missing-note creation should use the same project-route normalization as existing-note resolution, without stripping legitimate directory names merely because they match a project name. An explicit no-create mode for editing missing notes could also help clients avoid accidental creation.

basic-memory-edit-note-fix.patch

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions