{"record":{"id":"853fd942f566da55","repo":"thedotmack/claude-mem","slug":"corpus-name-not-found","errorCode":null,"errorMessage":"Corpus \"${name}\" not found","messagePattern":"Corpus \"(.+?)\" not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"src/services/worker/http/routes/CorpusRoutes.ts","lineNumber":84,"sourceCode":"    private corpusBuilder: CorpusBuilder,\n    private knowledgeAgent: KnowledgeAgent\n  ) {\n    super();\n  }\n\n  setupRoutes(app: express.Application): void {\n    app.post('/api/corpus', validateBody(buildCorpusSchema), this.handleBuildCorpus.bind(this));\n    app.get('/api/corpus', this.handleListCorpora.bind(this));\n    app.get('/api/corpus/:name', this.handleGetCorpus.bind(this));\n    app.delete('/api/corpus/:name', this.handleDeleteCorpus.bind(this));\n    app.post('/api/corpus/:name/rebuild', this.handleRebuildCorpus.bind(this));\n    app.post('/api/corpus/:name/prime', this.handlePrimeCorpus.bind(this));\n    app.post('/api/corpus/:name/query', validateBody(queryCorpusSchema), this.handleQueryCorpus.bind(this));\n    app.post('/api/corpus/:name/reprime', this.handleReprimeCorpus.bind(this));\n  }\n\n  private corpusNotFound(res: Response, name: string): void {\n    res.status(404).json({\n      error: `Corpus \"${name}\" not found`,\n      fix: 'Check the corpus name or build a new one',\n      available: this.corpusStore.list().map(c => c.name)\n    });\n  }\n\n  private handleBuildCorpus = this.wrapHandler(async (req: Request, res: Response): Promise<void> => {\n    const { name, description, project, types, concepts, files, query, date_start, date_end, limit } =\n      req.body as z.infer<typeof buildCorpusSchema>;\n\n    const filter: CorpusFilter = {};\n    if (project) filter.project = project;\n    if (types && types.length > 0) filter.types = types as CorpusFilter['types'];\n    if (concepts && concepts.length > 0) filter.concepts = concepts;\n    if (files && files.length > 0) filter.files = files;\n    if (query) filter.query = query;\n    if (date_start) filter.date_start = date_start;\n    if (date_end) filter.date_end = date_end;","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/services/worker/http/routes/CorpusRoutes.ts#L66-L102","documentation":"HTTP 404 from CorpusRoutes.corpusNotFound, returned by every /api/corpus/:name handler (GET, DELETE, rebuild, prime, query, reprime) when the named corpus is not in the in-memory corpus store. The body is richer than a plain 404: it includes a fix hint and an available array listing corpora that do exist, so the correct name is one field away.","triggerScenarios":"Querying or rebuilding a corpus name that was never built, was deleted, or whose build failed earlier; case mismatches in the name; using an id instead of the human name.","commonSituations":"Prompts or scripts hardcoding a corpus name like 'default' after the user renamed or removed it; querying right after a fresh install where no corpus exists yet; a build that appeared to succeed but actually errored.","solutions":["Read the available array in the 404 body and use one of those exact names","If none exist, build one first: POST /api/corpus with the desired filter (project, concepts, files, date range)","Check for case/exact-match differences — lookup is by exact name string"],"exampleFix":"// before\nconst r = await fetch(`${base}/api/corpus/Default/query`, { method: 'POST', body: JSON.stringify({ q: 'hooks' }) });\n// 404: available: [\"default-project\"]\n\n// after\nconst r = await fetch(`${base}/api/corpus/default-project/query`, { method: 'POST', body: JSON.stringify({ q: 'hooks' }) });","handlingStrategy":"validation","validationCode":"async function firstAvailableCorpus(base: string, fallback?: string): Promise<string | undefined> {\n  const list = await (await fetch(`${base}/api/corpus`)).json();\n  const names: string[] = (list.corpora ?? []).map((c: { name: string }) => c.name);\n  return names.includes(fallback ?? '') ? fallback : names[0];\n}","typeGuard":"interface CorpusNotFoundBody {\n  error: string;\n  fix: string;\n  available: string[];\n}\nfunction isCorpusNotFound(body: unknown, status: number): body is CorpusNotFoundBody {\n  return status === 404 && Array.isArray((body as { available?: unknown })?.available);\n}","tryCatchPattern":"const res = await callApi();\nif (res.status === 404) {\n  const body = await res.json();\n  if (isCorpusNotFound(body, res.status))\n    return retryWith(body.available[0]); // self-heal using the provided list\n  throw new Error('corpus route failed');\n}","preventionTips":["Discover corpus names at runtime via GET /api/corpus instead of hardcoding them","After a fresh install, build a corpus before any query/rebuild/prime call","Use exact names (case-sensitive) — copy from the available array"],"tags":["http-404","corpus","embeddings","lookup"],"backgroundTag":"http-404-resource-not-found","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","contentChangedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}