diegosouzapw/OmniRoute · error
Memory does not belong to this API key
Error message
Memory does not belong to this API key
What it means
Authorization guard in assertOwner: the memory record exists, but its owning apiKeyId does not match the calling context's apiKeyId. Each API key only sees its own memories; this rejection prevents cross-key access even when the id is valid — it is a tenancy boundary, not a missing record.
Solutions
- Use the API key that originally created the memory
- List memories under the current key and operate on those ids only
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/lib/skills/memoryBuiltins.ts:39 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/45e997be97b956ee.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/skills/memoryBuiltins.ts:39
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 }) {
const { type, key, content, metadata } = input as {
type?: string;View on GitHub (pinned to a179ffed5b)