Skip to content

[BUG] UNIQUE constraint failed: entity.permalink #139

@groksrc

Description

@groksrc

Bug Description

SQL Statment [SQL: INSERT INTO entity (title, entity_type, entity_metadata, content_type, permalink, file_path, checksum, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)] fails with the error sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: entity.permalink

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install version basic-machines 'v0.13.5'
  2. Issue a prompt that causes Claude to use tool the write_note to write a note
  3. Issue a prompt that causes Claude to use tool the write_note to write a second note
  4. Issue a prompt that tells Claude to replace the first note with the second note

Expected Behavior

The second note replaces the first note. There is only one note.

Actual Behavior

The update fails

Environment

  • OS: macOS 15.1.1
  • Python version: 3.13.0
  • Basic Memory version: 0.13.5
  • Installation method: uv
  • Claude Desktop version (if applicable): Claude 0.10.14 (27cc6f763724a1af75b35c386a6b8d014eedc334) 2025-06-05T15:01:12.000Z

basic-memory-mcp.2025-06-17_15-29-404741.log

Additional Context

  • See attached basic-memory log file

Possible Solution

  • Catch this specific error and handle it as a drop/create in a transaction (write optimistic) Or
  • Look up the permalink before attempting a write, and if found remove it, then write (write pessimistic) Or
  • Do not change the permalink

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