FoundationAgents/MetaGPT · error · Exception
Table not created yet, please add data first.
Error message
Table not created yet, please add data first.
What it means
LanceStore.search raises a plain Exception when self.table is None. The table is only created lazily by LanceStore.add (which calls db.create_table on the first insertion), so searching a store that never received data — or one whose table was dropped — fails with 'Table not created yet, please add data first.'.
Source
Thrown at metagpt/document_store/lancedb_store.py:29
import lancedb
class LanceStore:
def __init__(self, name):
db = lancedb.connect("./data/lancedb")
self.db = db
self.name = name
self.table = None
def search(self, query, n_results=2, metric="L2", nprobes=20, **kwargs):
# This assumes query is a vector embedding
# kwargs can be used for optional filtering
# .select - only searches the specified columns
# .where - SQL syntax filtering for metadata (e.g. where("price > 100"))
# .metric - specifies the distance metric to use
# .nprobes - values will yield better recall (more likely to find vectors if they exist) at the expense of latency.
if self.table is None:
raise Exception("Table not created yet, please add data first.")
results = (
self.table.search(query)
.limit(n_results)
.select(kwargs.get("select"))
.where(kwargs.get("where"))
.metric(metric)
.nprobes(nprobes)
.to_df()
)
return results
def persist(self):
raise NotImplementedError
def write(self, data, metadatas, ids):
# This function is similar to add(), but it's for more generalized updates
# "data" is the list of embeddingsView on GitHub (pinned to 11cdf466d0)
Solutions
- Call store.add(...) (or add_n_docs / your ingestion path) at least once before search so the table is created via db.create_table.
- If data was previously persisted, reopen the table explicitly instead of relying on lazy creation: store.table = store.db.open_table(store.name) before searching.
- If operating on a shared db, verify the table exists: if name in [t.name for t in db.table_names()]: store.table = db.open_table(name).
- Check for empty store at the application level and skip the search when nothing has been ingested yet.
Example fix
# before
store = LanceStore(db, "docs")
results = store.search(query_vec) # Exception: Table not created yet
# after
store = LanceStore(db, "docs")
if "docs" in db.table_names():
store.table = db.open_table("docs")
else:
store.add("", query_vec, {}) # creates table on first add
results = store.search(query_vec) Defensive patterns
Strategy: validation
Validate before calling
def ensure_lance_table(store, db):
"""Reopen or create the table so search() has something to query."""
if store.table is None:
if store.name in db.table_names():
store.table = db.open_table(store.name)
else:
raise ValueError(f"no data ingested for table '{store.name}'; call add() first") Try / catch
try:
results = store.search(qvec, n_results=5)
except Exception as e:
if "Table not created yet" in str(e):
raise RuntimeError("vector store is empty; ingest documents before querying") from e
raise Prevention
- Always run at least one add() (or reopen the persisted table) in the same LanceStore instance before search.
- Treat an empty store as an application-level condition: skip the search when the collection is empty rather than relying on the exception.
- In long-lived services, construct/reopen tables at startup and fail fast there instead of on the first query.
When it happens
Trigger: Instantiating LanceStore(db, name) and calling search(query_vector, ...) before any successful add() call; or calling search after drop() removed the underlying .lance directory while the instance still exists.
Common situations: Fresh vector store in a new session being queried before ingestion; a crashed/interrupted first add() that never created the table; mixing a persisted db path with a new LanceStore object and assuming the table auto-reopens (it does not — this wrapper keeps table=None until add).
Related errors
- Table not created yet, please add data first
- please check QdrantConnection.
- Delete collection {collection_name} failed.
- Missing fields: {missing_fields}
- use `review` after `fill`
AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14).
Data as JSON: /api/errors/8092f70ea5b14dec.
Report an issue: GitHub.