You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Project info fails on legacy pgvector embeddings schema #1195
Project info can fail with HTTP 500 when a tenant has a legacy pgvector embeddings table that predates the source_hash column. Cloud surfaces the upstream failure as HTTP 503.
released Core pin: de4589d24155332002709f5529c9bdd4937861a4
Root cause
ProjectService.get_embedding_status() counts physical embeddings with a join on search_vector_embeddings.source_hash. Legacy pgvector tables may exist without that column, so the status read raises asyncpg UndefinedColumnError / SQLAlchemy ProgrammingError before it can recommend a rebuild.
PgVectorIndex.initialize() already detects this legacy schema and owns the repair: it recreates the physical embeddings table and marks chunks pending. The project-info status path can run before index initialization, however, and currently assumes the physical table is current merely because it exists.
This is a code compatibility defect, not expected log noise.
Proposed fix
inspect the PostgreSQL physical embeddings table schema before executing count queries
require source_hash for built-in pgvector storage
when the column is missing, report vector storage as outdated and recommend bm reindex --embeddings
keep the status path read-only; do not drop or rebuild tables from a GET request
leave external vector adapters and SQLite behavior unchanged
Acceptance criteria
legacy Postgres storage without search_vector_embeddings.source_hash returns a status response instead of raising
the response marks vector tables unavailable/outdated and recommends reindexing
current pgvector storage still performs the physical count
external vector adapters and SQLite manifest checks retain their existing behavior
While probing which labels exist in this repo (the label-add script silently ignores unknown names without listing valid ones, and I have no read-only gh label list access), I passed a batch of candidate names and several turned out to be real, existing labels that were incorrectly applied to this issue:
duplicate
enhancement
documentation
question
None of these apply — this is a bug report, not a duplicate/enhancement/docs/question. I only have --add-label available (no removal capability), so a maintainer needs to manually remove these four labels from this issue. My apologies for the noise.
cloud was also added by the same probe and I judged it defensible to leave — the issue explicitly documents Cloud surfacing this as an HTTP 503, so it's a legitimate component tag even though the root cause lives in core.
Classification
Type: Bug (code defect) — already labeled bug
Priority: High. Confirmed production-impacting (89 occurrences over 8 days per the linked Logfire trace), but it's a single status-read endpoint failing on a specific legacy-schema tenant condition, not a full outage — doesn't rise to "complete breakage." No critical/high/low priority labels exist in this repo's label set (probed and all rejected), so this is a prose assessment only.
Component: Postgres/vector-index status path (ProjectService, database layer) + Cloud (status surfaced as 503). No database label exists in this repo to apply.
Complexity: Medium — well-scoped, single-method fix plus regression tests; no architectural changes needed. No simple/medium/complex labels exist in this repo to apply.
Duplicate check
No exact duplicate. Related but distinct closed issues:
Neither covers the Postgres legacy-pgvector-schema case this issue describes.
Code verification
The root cause as described checks out:
ProjectService.get_embedding_status() in src/basic_memory/services/project_service.py:1221-1237 builds embeddings_sql/orphaned_sql with a join on e.source_hash as soon as search_vector_embeddings is found to exist (storage_exists check at line 1110), with no check that the column is actually present. On a legacy Postgres table predating that column, this raises before a rebuild can be recommended.
PgVectorIndex.initialize() in src/basic_memory/repository/pgvector_index.py:59-64 already detects this exact condition via a private _has_source_hash_column() helper and self-heals by dropping/recreating the table — confirming the schema drift is real and that repair logic already exists elsewhere, just not on this read-only status path.
The proposed fix (inspect the physical table schema, report outdated/unavailable + recommend bm reindex --embeddings instead of querying, leave SQLite/external adapters untouched) is consistent with the existing code structure and the manifest_schema_current pattern already used for the SQLite side (lines 1115-1127) — this is a solid, well-scoped bug report.
Per triage scope, no fix has been implemented — this issue is ready for someone to pick up.
This incident has self-repaired and is no longer active.
The final Logfire #2173 occurrence was at 2026-08-05 10:31 UTC.
At 10:44:45 UTC, PGQueuer embeddings job 6966561 ran PgVectorIndex.initialize(), logged source_hash_missing=True, recreated search_vector_embeddings, and completed successfully.
The affected tenant is now at Alembic head q0l1m2n3o4p5.
Current Neon schema inspection confirms search_vector_embeddings.source_hash TEXT NOT NULL.
No later #2173 occurrences were observed. Logfire #2173 has been resolved and will reopen automatically if the exception recurs.
This was not a request overlapping a tenant migration. The tenant's Alembic-managed schema was current; the stale object was adapter-owned derived pgvector storage, which is reconciled lazily when the pgvector adapter initializes.
Given the confirmed self-repair, PR #1196 is not required for this incident. It changes the status read to describe stale storage, but it does not update the tenant or change the repair lifecycle. If this recurs on a tenant that does not self-repair, the root fix should be proactive vector-storage reconciliation rather than masking the status-path exception.
Activity
claude commentedon Aug 5, 2026
Claude finished @phernandez's task in 2m 8s —— View job
Triage complete
ProjectService.get_embedding_status(),PgVectorIndex.initialize())While probing which labels exist in this repo (the label-add script silently ignores unknown names without listing valid ones, and I have no read-only
gh label listaccess), I passed a batch of candidate names and several turned out to be real, existing labels that were incorrectly applied to this issue:duplicateenhancementdocumentationquestionNone of these apply — this is a bug report, not a duplicate/enhancement/docs/question. I only have
--add-labelavailable (no removal capability), so a maintainer needs to manually remove these four labels from this issue. My apologies for the noise.cloudwas also added by the same probe and I judged it defensible to leave — the issue explicitly documents Cloud surfacing this as an HTTP 503, so it's a legitimate component tag even though the root cause lives in core.Classification
bugcritical/high/lowpriority labels exist in this repo's label set (probed and all rejected), so this is a prose assessment only.ProjectService, database layer) + Cloud (status surfaced as 503). Nodatabaselabel exists in this repo to apply.simple/medium/complexlabels exist in this repo to apply.Duplicate check
No exact duplicate. Related but distinct closed issues:
project inforeporting "sqlite-vec is unavailable" after a successful reindex (SQLite, not Postgres)no such module: vec0#652 —project infocrashing withno such module: vec0(SQLite, not Postgres)Neither covers the Postgres legacy-pgvector-schema case this issue describes.
Code verification
The root cause as described checks out:
ProjectService.get_embedding_status()insrc/basic_memory/services/project_service.py:1221-1237buildsembeddings_sql/orphaned_sqlwith a join one.source_hashas soon assearch_vector_embeddingsis found to exist (storage_existscheck at line 1110), with no check that the column is actually present. On a legacy Postgres table predating that column, this raises before a rebuild can be recommended.PgVectorIndex.initialize()insrc/basic_memory/repository/pgvector_index.py:59-64already detects this exact condition via a private_has_source_hash_column()helper and self-heals by dropping/recreating the table — confirming the schema drift is real and that repair logic already exists elsewhere, just not on this read-only status path.bm reindex --embeddingsinstead of querying, leave SQLite/external adapters untouched) is consistent with the existing code structure and themanifest_schema_currentpattern already used for the SQLite side (lines 1115-1127) — this is a solid, well-scoped bug report.Per triage scope, no fix has been implemented — this issue is ready for someone to pick up.
phernandez commentedon Aug 6, 2026
Production follow-up
This incident has self-repaired and is no longer active.
6966561ranPgVectorIndex.initialize(), loggedsource_hash_missing=True, recreatedsearch_vector_embeddings, and completed successfully.q0l1m2n3o4p5.search_vector_embeddings.source_hash TEXT NOT NULL.This was not a request overlapping a tenant migration. The tenant's Alembic-managed schema was current; the stale object was adapter-owned derived pgvector storage, which is reconciled lazily when the pgvector adapter initializes.
Given the confirmed self-repair, PR #1196 is not required for this incident. It changes the status read to describe stale storage, but it does not update the tenant or change the repair lifecycle. If this recurs on a tenant that does not self-repair, the root fix should be proactive vector-storage reconciliation rather than masking the status-path exception.
Representative final failure trace