Bug Report
Description
ghost_memory_save fails with a UNIQUE constraint error when saving memories for a project whose path field equals its id (i.e. a non-filesystem path).
Error Message
ensure project: constraint failed: UNIQUE constraint failed: projects.path (2067)
Steps to Reproduce
- Have a project with a non-filesystem path where
id == path (e.g. a7293a04b38a)
- Call
ghost_memory_save with either the project name (e.g. project_id="dingo") or the internal id (e.g. project_id="a7293a04b38a")
- Observe the error:
ensure project: constraint failed: UNIQUE constraint failed: projects.path (2067)
Expected Behavior
ghost_memory_save should succeed regardless of whether the project's path field is a filesystem path or a non-filesystem identifier.
Actual Behavior
The save operation fails. ghost_list_projects shows the affected project has path: a7293a04b38a (same value as id) rather than a real filesystem path. The error suggests that the "ensure project" logic (likely an upsert or insert-if-not-exists) is performing a duplicate insert — possibly a race condition or a code path that doesn't correctly handle the case where path == id.
Additional Context
- The error code
2067 is SQLite's SQLITE_CONSTRAINT_UNIQUE.
- The bug affects both lookup-by-name and lookup-by-internal-id.
- Projects with a proper filesystem path (e.g.
/home/user/git/myrepo) do not appear to trigger this issue.
- Likely cause: the
ensure project function may be doing a SELECT followed by an INSERT without proper conflict handling, or the upsert clause targets the wrong unique column, causing a second insert attempt when path already exists.
Suggested Fix
Review the ensure project database logic to use an INSERT OR IGNORE / ON CONFLICT DO NOTHING (or equivalent upsert) that correctly deduplicates on projects.path, and verify it handles the id == path case without attempting a second insert.
Bug Report
Description
ghost_memory_savefails with a UNIQUE constraint error when saving memories for a project whosepathfield equals itsid(i.e. a non-filesystem path).Error Message
Steps to Reproduce
id == path(e.g.a7293a04b38a)ghost_memory_savewith either the project name (e.g.project_id="dingo") or the internal id (e.g.project_id="a7293a04b38a")ensure project: constraint failed: UNIQUE constraint failed: projects.path (2067)Expected Behavior
ghost_memory_saveshould succeed regardless of whether the project'spathfield is a filesystem path or a non-filesystem identifier.Actual Behavior
The save operation fails.
ghost_list_projectsshows the affected project haspath: a7293a04b38a(same value asid) rather than a real filesystem path. The error suggests that the "ensure project" logic (likely an upsert or insert-if-not-exists) is performing a duplicate insert — possibly a race condition or a code path that doesn't correctly handle the case wherepath == id.Additional Context
2067is SQLite'sSQLITE_CONSTRAINT_UNIQUE./home/user/git/myrepo) do not appear to trigger this issue.ensure projectfunction may be doing aSELECTfollowed by anINSERTwithout proper conflict handling, or the upsert clause targets the wrong unique column, causing a second insert attempt whenpathalready exists.Suggested Fix
Review the
ensure projectdatabase logic to use anINSERT OR IGNORE/ON CONFLICT DO NOTHING(or equivalent upsert) that correctly deduplicates onprojects.path, and verify it handles theid == pathcase without attempting a second insert.