thedotmack/claude-mem · error

Corpus " " not found

Error message

Corpus "${name}" not found

What it means

corpusNotFound is the shared 404 responder for all :name-parameterized corpus routes (get/delete/rebuild/prime/query/reprime). When the requested corpus name is absent from the corpusStore, the route replies 404 with the corpus name, a fix hint, and the list of available corpus names.

Solutions

  1. Check the 'available' array in the 404 response and retry with a valid corpus name
  2. Build the corpus first (POST /api/corpus/:name/build or equivalent) before querying/priming it
  3. Fix the name typo in the client configuration
  4. If the corpus existed before a restart, verify the database/storage location is the one you expect

Example fix

// before
curl -X POST http://localhost:37777/api/corpus/my-corpus/query -d '{...}'  // 404
// after
curl http://localhost:37777/api/corpus  # list available names
curl -X POST http://localhost:37777/api/corpus/<name-from-list>/query -d '{...}'
Defensive patterns

Strategy: validation

Validate before calling

const corpora = await (await fetch('http://localhost:37777/api/corpus')).json();
if (!corpora.map(c => c.name).includes(name)) throw new Error(`Corpus "${name}" does not exist; available: ${corpora.map(c => c.name).join(', ')}`);

Try / catch

const res = await fetch(`/api/corpus/${encodeURIComponent(name)}/query`, { method: 'POST', ... });
if (res.status === 404) {
  const body = await res.json();
  throw new Error(`${body.error} — available: ${body.available.join(', ')}`);
}

Prevention

When it happens

Trigger: GET/DELETE /api/corpus/:name, POST /api/corpus/:name/{rebuild,prime,query,reprime} with a :name that does not exist in the corpus store.

Common situations: Typo in the corpus name; corpus was deleted or never built; worker restarted with a fresh database so previously built corpora are gone; stale client cache referencing an old corpus.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17). Data as JSON: /api/errors/853fd942f566da55. Report an issue: GitHub.

Appendix: source

Thrown at src/services/worker/http/routes/CorpusRoutes.ts:84

    private corpusBuilder: CorpusBuilder,
    private knowledgeAgent: KnowledgeAgent
  ) {
    super();
  }

  setupRoutes(app: express.Application): void {
    app.post('/api/corpus', validateBody(buildCorpusSchema), this.handleBuildCorpus.bind(this));
    app.get('/api/corpus', this.handleListCorpora.bind(this));
    app.get('/api/corpus/:name', this.handleGetCorpus.bind(this));
    app.delete('/api/corpus/:name', this.handleDeleteCorpus.bind(this));
    app.post('/api/corpus/:name/rebuild', this.handleRebuildCorpus.bind(this));
    app.post('/api/corpus/:name/prime', this.handlePrimeCorpus.bind(this));
    app.post('/api/corpus/:name/query', validateBody(queryCorpusSchema), this.handleQueryCorpus.bind(this));
    app.post('/api/corpus/:name/reprime', this.handleReprimeCorpus.bind(this));
  }

  private corpusNotFound(res: Response, name: string): void {
    res.status(404).json({
      error: `Corpus "${name}" not found`,
      fix: 'Check the corpus name or build a new one',
      available: this.corpusStore.list().map(c => c.name)
    });
  }

  private handleBuildCorpus = this.wrapHandler(async (req: Request, res: Response): Promise<void> => {
    const { name, description, project, types, concepts, files, query, date_start, date_end, limit } =
      req.body as z.infer<typeof buildCorpusSchema>;

    const filter: CorpusFilter = {};
    if (project) filter.project = project;
    if (types && types.length > 0) filter.types = types as CorpusFilter['types'];
    if (concepts && concepts.length > 0) filter.concepts = concepts;
    if (files && files.length > 0) filter.files = files;
    if (query) filter.query = query;
    if (date_start) filter.date_start = date_start;
    if (date_end) filter.date_end = date_end;

View on GitHub (pinned to d8bc9755e7)