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.delete raises a plain Exception when self.table is None. Deletion requires an existing table, which is only created by a prior successful add(); calling delete on a store that never ingested data has nothing to delete and the wrapper rejects it explicitly rather than silently succeeding.

Solutions

  1. Ensure add() ran at least once in this process, or reopen the persisted table: store.table = store.db.open_table(store.name).
  2. Guard deletion: if store.table is None: skip or log, since there is nothing to delete.
  3. Verify the table exists via db.table_names() before constructing the store's delete path.

Example fix

# before
store.delete("doc-42")  # Exception: Table not created yet

# after
if store.table is not None:
    store.delete("doc-42")
else:
    logger.info("nothing to delete, table does not exist")
Defensive patterns

Strategy: validation

Validate before calling

def safe_delete(store, _id):
    if store.table is None:
        return False  # nothing ingested, nothing to delete
    store.delete(_id)
    return True

Try / catch

try:
    store.delete(_id)
except Exception as e:
    if "Table not created yet" not in str(e):
        raise  # only swallow the empty-store case

Prevention

When it happens

Trigger: Calling store.delete(_id) on a LanceStore instance where add() was never called, or after the table was dropped. The id is formatted into a SQL filter ('id = ...' or "id = '...'") and passed to table.delete.

Common situations: Cleanup/rerank scripts that delete stale vectors before ingestion runs; a new process pointing at an existing db path but never reopening the table; test teardown deleting from a store that the test never populated.

Related errors


AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14). Data as JSON: /api/errors/cb43f49a77fe1216. Report an issue: GitHub.

Appendix: source

Thrown at metagpt/document_store/lancedb_store.py:77

            self.table = self.db.create_table(self.name, documents)

    def add(self, data, metadata, _id):
        # This function is for adding individual documents
        # It assumes you're passing in a single vector embedding, metadata, and id

        row = {"vector": data, "id": _id}
        row.update(metadata)

        if self.table is not None:
            self.table.add([row])
        else:
            self.table = self.db.create_table(self.name, [row])

    def delete(self, _id):
        # This function deletes a row by id.
        # LanceDB delete syntax uses SQL syntax, so you can use "in" or "="
        if self.table is None:
            raise Exception("Table not created yet, please add data first")

        if isinstance(_id, str):
            return self.table.delete(f"id = '{_id}'")
        else:
            return self.table.delete(f"id = {_id}")

    def drop(self, name):
        # This function drops a table, if it exists.

        path = os.path.join(self.db.uri, name + ".lance")
        if os.path.exists(path):
            shutil.rmtree(path)

View on GitHub (pinned to 11cdf466d0)