Repository navigation
Description
Production impact
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.
Logfire issue: #2173
- issue UUID:
0ffef7ed-d15a-4d36-b020-319d63f86db3 - fingerprint:
ba0cf52630aa4a77881bdc13ef66a21126a303fa9809fb369a763445544ec248 - occurrences: 89 between 2026-07-28 and 2026-08-05
- representative trace: https://logfire-us.pydantic.dev/basic-memory/basic-memory-cloud/?q=trace_id%3D%27019fd17a9cbeda55ff702b28562e717f%27&since=2026-08-05T10%3A31%3A41.502000%2B00%3A00&until=2026-08-06T10%3A31%3A43.746509%2B00%3A00
- observed Cloud release:
690a258323b34834186a7284e29a2a7e39358168 - 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_hashfor 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_hashreturns 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
- regression tests cover the legacy schema path
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