affaan-m/ECC · error · Error

Memory ${memoryId} was not found.

Error message

Memory ${memoryId} was not found.

What it means

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.

Source

Thrown at scripts/lib/memory-vault.js:670

    },
  };
}

function readMemoryById(id, options = {}) {
  const memoryId = validateMemoryId(id);
  const targetHarness = options.targetHarness
    ? validateSlug(options.targetHarness, 'target harness')
    : null;
  const loaded = readMemoryFiles(options);
  const matches = loaded.entries
    .filter(entry => entry.memory.id === memoryId)
    .filter(entry => (
      !targetHarness
      || entry.memory.targetHarnesses.includes('all')
      || entry.memory.targetHarnesses.includes(targetHarness)
    ));
  if (matches.length === 0) {
    throw new Error(`Memory ${memoryId} was not found.`);
  }
  if (matches.length > 1) {
    throw new Error(`Memory ${memoryId} is duplicated in ${matches.length} files.`);
  }
  const allBacklinks = loaded.entries
    .filter(entry => entry.memory.links.includes(memoryId))
    .filter(entry => entry.memory.status === 'active')
    .map(entry => entry.memory)
    .filter(memory => (
      !targetHarness
      || memory.targetHarnesses.includes('all')
      || memory.targetHarnesses.includes(targetHarness)
    ))
    .sort((left, right) => left.id.localeCompare(right.id));
  const backlinks = allBacklinks
    .slice(0, MAX_RESULTS)
    .map(summarizeMemory);
  return {

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Verify the id with searchMemories({}) (empty query lists all) or doctorMemoryVault to confirm whether the memory exists at all.
  2. If using targetHarness, either drop the filter or ensure the memory's targetHarnesses includes 'all' or the harness you are querying from.
  3. Pass options.scopes covering where the memory lives (e.g. ['project','team','user']) — readMemoryById defaults to a restricted scope set.
  4. Check for typos: ids are case-sensitive and follow the mem_YYYYMMDD_<random> format.

Example fix

// before
const mem = readMemoryById('mem_x', { targetHarness: 'claude' }); // throws
// after: find where it actually lives
const { results } = searchMemories('', {});
const hit = results.find(r => r.memory.id === 'mem_x');
const mem = readMemoryById('mem_x', { scopes: ['user','project','team'] }); // no harness filter
Defensive patterns

Strategy: try-catch

Validate before calling

const { searchMemories } = require('./scripts/lib/memory-vault');
function memoryExists(id, options = {}) {
  const { results } = searchMemories('', options);
  return results.some(r => r.memory.id === id);
}
// before readMemoryById:
if (!memoryExists(id, options)) throw new Error(`Memory ${id} was not found.`);

Try / catch

try { return readMemoryById(id, options); }
catch (error) {
  if (/was not found/.test(error.message)) {
    console.error('Memory not present in the scanned scopes; check id, scopes, and targetHarness.');
    return null;
  }
  throw error;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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').

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/8fb3b186b5ccc6a9. Report an issue: GitHub.