diegosouzapw/OmniRoute · error

Memory not found

Error message

Memory not found: ${memoryId}

What it means

Lookup failure in assertOwner: getMemory(memoryId) returned null — no memory record with that id exists (already deleted, wrong id, or a stale reference). Ownership cannot be checked against a nonexistent row, so the operation fails before the per-API-key authorization comparison.

Solutions

  1. Verify the memory id and re-list memories to get a valid one
  2. Do not cache memory ids across deletions
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/lib/skills/memoryBuiltins.ts:37 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/fe07ac3fa52a0bcf. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/skills/memoryBuiltins.ts:37

] as const;

const MEMORY_TYPES = ["factual", "episodic", "procedural", "semantic"] as const;

function toMemoryType(value: unknown): MemoryType {
  return MEMORY_TYPES.includes(value as (typeof MEMORY_TYPES)[number])
    ? (value as MemoryType)
    : MemoryType.FACTUAL;
}

function toPositiveInt(value: unknown, fallback: number, max: number): number {
  const parsed = Number(value);
  if (!Number.isInteger(parsed) || parsed <= 0) return fallback;
  return Math.min(parsed, max);
}

async function assertOwner(memoryId: string, apiKeyId: string): Promise<void> {
  const memory = await getMemory(memoryId);
  if (!memory) throw new Error(`Memory not found: ${memoryId}`);
  if (memory.apiKeyId !== apiKeyId) {
    throw new Error("Memory does not belong to this API key");
  }
}

function memoryToPlain(memory: Awaited<ReturnType<typeof createMemory>>) {
  return {
    id: memory.id,
    type: memory.type,
    key: memory.key,
    content: memory.content,
    metadata: memory.metadata,
    createdAt: memory.createdAt.toISOString(),
    updatedAt: memory.updatedAt.toISOString(),
  };
}

async function handleMemorySave(input: Record<string, unknown>, context: { apiKeyId: string; sessionId: string }) {

View on GitHub (pinned to a179ffed5b)