Skip to content

Frontmatter keys cannot be deleted through a full-document save #1768

Closed

Description

@phernandez

What happens

A frontmatter key removed from a note's document is not removed from the file. A replace or overwrite keeps any key that the incoming document leaves out.

Seen in Basic Memory Cloud's web editor:

  1. A note's frontmatter has eaccess: write.
  2. The person deletes that line in the frontmatter editor and saves.
  3. The full new document goes to the save path without the key.
  4. After a reload, eaccess: write is back in the file.

Why

Core's update path merges the incoming metadata over the note's existing raw frontmatter before it dumps the YAML: services/note_preparation.py, prepare_update_entity_content (around line 465), after schema_to_markdown. A key that is absent from the new document survives from the old one.

This merge is intended for MCP write_note with overwrite=True, whose docs say: "Overwrite replaces the body but merges frontmatter: keys the existing note has and this write does not set are kept". That rule is wrong for a caller that sends the whole canonical document. An editor saving the full file means "this is the file", and the only way to delete a key should be to leave it out.

Expected

When a write supplies the complete document (frontmatter plus body), the resulting frontmatter is exactly what was supplied. Keys left out are removed. The MCP overwrite merge can stay as it is for callers that only set some fields, but a full-document replace needs a path that does not merge.

Repro

  • Note with frontmatter title, type, extra: 1.
  • Save the full document without extra through the accepted-note replace path, which is what Cloud's PUT /api/v2/notes/{id} uses.
  • Read the file: extra: 1 is still there.

Related

Cloud had a separate bug on the same save path: frontmatter booleans and numbers were stringified (enabled: true became enabled: 'True') because the payload was built from the normalized index metadata. That one is being fixed in Cloud. This issue is only about deleted keys coming back.

Activity

  1. added
    bug
    on Oct 16, 2026
  2. claude commented on Oct 16, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 13s —— View job


    Triage

    • Type: Bug
    • Component: Cloud-facing (the accepted-note replace path behind PUT /api/v2/notes/{id}). The defect itself is in core, in the services/note preparation layer.
    • Priority: Medium. A deleted frontmatter key comes back after save. That's a data-correctness problem for full-document editors, but the note body is not corrupted and there is a workaround: set the key to an empty value rather than removing it.
    • Complexity: Medium. The fix needs a replace path that skips the existing-frontmatter merge in prepare_update_entity_content (services/note_preparation.py), while keeping the merge for MCP write_note(overwrite=True). The main work is deciding how callers opt in to full-document semantics, plus regression tests on the accepted-note replace path.

    Duplicates: I found no exact duplicate. #1653 is related: it covers write_note overwrite merge-preserving frontmatter keys and says the tool documents replacement. It looks at the same merge from the MCP side, so any decision on the merge semantics should be coordinated with it.

    The issue has a clear repro and expected behavior, so I don't need more information. Per triage scope, I haven't made any code changes.

  3. added
    cloud
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcloud

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions