{"record":{"id":"8fb3b186b5ccc6a9","repo":"affaan-m/ECC","slug":"memory-memoryid-was-not-found","errorCode":null,"errorMessage":"Memory ${memoryId} was not found.","messagePattern":"Memory (.+?) was not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/memory-vault.js","lineNumber":670,"sourceCode":"    },\n  };\n}\n\nfunction readMemoryById(id, options = {}) {\n  const memoryId = validateMemoryId(id);\n  const targetHarness = options.targetHarness\n    ? validateSlug(options.targetHarness, 'target harness')\n    : null;\n  const loaded = readMemoryFiles(options);\n  const matches = loaded.entries\n    .filter(entry => entry.memory.id === memoryId)\n    .filter(entry => (\n      !targetHarness\n      || entry.memory.targetHarnesses.includes('all')\n      || entry.memory.targetHarnesses.includes(targetHarness)\n    ));\n  if (matches.length === 0) {\n    throw new Error(`Memory ${memoryId} was not found.`);\n  }\n  if (matches.length > 1) {\n    throw new Error(`Memory ${memoryId} is duplicated in ${matches.length} files.`);\n  }\n  const allBacklinks = loaded.entries\n    .filter(entry => entry.memory.links.includes(memoryId))\n    .filter(entry => entry.memory.status === 'active')\n    .map(entry => entry.memory)\n    .filter(memory => (\n      !targetHarness\n      || memory.targetHarnesses.includes('all')\n      || memory.targetHarnesses.includes(targetHarness)\n    ))\n    .sort((left, right) => left.id.localeCompare(right.id));\n  const backlinks = allBacklinks\n    .slice(0, MAX_RESULTS)\n    .map(summarizeMemory);\n  return {","sourceCodeStart":652,"sourceCodeEnd":688,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/memory-vault.js#L652-L688","documentation":"readMemoryById scans all in-scope memories and filters by id (and optionally by targetHarness). If no entry matches both the requested id and the harness filter, it throws 'not found'. The check is post-scan, so the id is known to be valid format-wise (validateMemoryId ran first) — the memory simply is not present in the visible vault, or is present but excluded by the targetHarness filter.","triggerScenarios":"Calling readMemoryById with an id that does not exist in any scanned scope, or that exists but whose targetHarnesses list does not include the requested targetHarness (and does not include 'all'). Also fires if the memory lives in a scope not included in the read options (readMemoryById uses default scopes when options.scopes is not set).","commonSituations":"Looking up an id from a different machine or user (vault is per-user/per-project); typo in the id; the memory was deleted; targetHarness filter excludes it (memory pinned to 'kimi' but you query with targetHarness 'claude'); scope mismatch (memory in 'user' but you only scanned 'project').","solutions":["Verify the id with searchMemories({}) (empty query lists all) or doctorMemoryVault to confirm whether the memory exists at all.","If using targetHarness, either drop the filter or ensure the memory's targetHarnesses includes 'all' or the harness you are querying from.","Pass options.scopes covering where the memory lives (e.g. ['project','team','user']) — readMemoryById defaults to a restricted scope set.","Check for typos: ids are case-sensitive and follow the mem_YYYYMMDD_<random> format."],"exampleFix":"// before\nconst mem = readMemoryById('mem_x', { targetHarness: 'claude' }); // throws\n// after: find where it actually lives\nconst { results } = searchMemories('', {});\nconst hit = results.find(r => r.memory.id === 'mem_x');\nconst mem = readMemoryById('mem_x', { scopes: ['user','project','team'] }); // no harness filter","handlingStrategy":"try-catch","validationCode":"const { searchMemories } = require('./scripts/lib/memory-vault');\nfunction memoryExists(id, options = {}) {\n  const { results } = searchMemories('', options);\n  return results.some(r => r.memory.id === id);\n}\n// before readMemoryById:\nif (!memoryExists(id, options)) throw new Error(`Memory ${id} was not found.`);","typeGuard":null,"tryCatchPattern":"try { return readMemoryById(id, options); }\ncatch (error) {\n  if (/was not found/.test(error.message)) {\n    console.error('Memory not present in the scanned scopes; check id, scopes, and targetHarness.');\n    return null;\n  }\n  throw error;\n}","preventionTips":["Confirm ids with searchMemories({}) before lookups.","Pass options.scopes covering project, team, and user when unsure where a memory lives.","Drop the targetHarness filter if you do not need it, or ensure memories use targetHarnesses: ['all'].","Treat ids as case-sensitive — copy them verbatim."],"tags":["memory-vault","validation","search","not-found"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}