diegosouzapw/OmniRoute · error · Error

memory not found

Error message

memory not found: ${memoryId}

What it means

upsertVector's lookup of the memory by UUID id in the memories table returned no row, so there is no rowid to insert into vec_memories. The memory was deleted (or never committed) before its vector arrived.

Solutions

  1. Skip the upsert — the parent memory no longer exists
  2. Ensure memory creation commits before enqueueing vector generation
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/lib/memory/vectorStore.ts:214 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/2c98dba3a5ef90a9. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/memory/vectorStore.ts:214

      } catch (err: unknown) {
        const msg = sanitizeErrorMessage(err instanceof Error ? err.message : String(err));
        return { ready: false, reason: `failed to create vec_memories: ${msg}` };
      }
    }

    return { ready: false, reason: "no dimensions available yet (lazy probe pending)" };
  }

  async upsertVector(memoryId: string, vector: Float32Array): Promise<void> {
    const db = getDbInstance();

    // Map UUID memoryId → INTEGER rowid (the rowid is used as the FK into vec_memories).
    const row = db.prepare("SELECT rowid FROM memories WHERE id = ?").get(memoryId) as
      | { rowid: number }
      | undefined;

    if (!row) {
      throw new Error(`memory not found: ${memoryId}`);
    }

    // vec0 v0.1.9 requires BigInt for explicit rowid insertion — plain numbers are rejected.
    // INSERT OR REPLACE is not supported by vec0 — use DELETE + INSERT for upsert semantics.
    // int8 tables quantize the float32 blob in SQL (vec_quantize_int8); float32 bind raw.
    const q = liveVecQuantization();
    try {
      db.prepare("DELETE FROM vec_memories WHERE rowid = ?").run(BigInt(row.rowid));
      db.prepare(`INSERT INTO vec_memories(rowid, embedding) VALUES (?, ${vecValueExpr(q)})`).run(
        BigInt(row.rowid),
        encodeVector(vector),
      );
    } catch (err: unknown) {
      // Self-heal: a concurrent ensureReady()'s reset raced ahead of us and
      // dropped the table after our own ensureReady() already ran. Recreate
      // from the last-known-good meta and retry once before giving up.
      if (!isMissingVecTableError(err) || !recreateFromMeta()) throw err;
      db.prepare("DELETE FROM vec_memories WHERE rowid = ?").run(BigInt(row.rowid));

View on GitHub (pinned to a179ffed5b)