{"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/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/worker/http/routes/CorpusRoutes.ts#L66-L102","documentation":"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.","triggerScenarios":"GET/DELETE /api/corpus/:name, POST /api/corpus/:name/{rebuild,prime,query,reprime} with a :name that does not exist in the corpus store.","commonSituations":"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.","solutions":["Check the 'available' array in the 404 response and retry with a valid corpus name","Build the corpus first (POST /api/corpus/:name/build or equivalent) before querying/priming it","Fix the name typo in the client configuration","If the corpus existed before a restart, verify the database/storage location is the one you expect"],"exampleFix":"// before\ncurl -X POST http://localhost:37777/api/corpus/my-corpus/query -d '{...}'  // 404\n// after\ncurl http://localhost:37777/api/corpus  # list available names\ncurl -X POST http://localhost:37777/api/corpus/<name-from-list>/query -d '{...}'","handlingStrategy":"validation","validationCode":"const corpora = await (await fetch('http://localhost:37777/api/corpus')).json();\nif (!corpora.map(c => c.name).includes(name)) throw new Error(`Corpus \"${name}\" does not exist; available: ${corpora.map(c => c.name).join(', ')}`);","typeGuard":null,"tryCatchPattern":"const res = await fetch(`/api/corpus/${encodeURIComponent(name)}/query`, { method: 'POST', ... });\nif (res.status === 404) {\n  const body = await res.json();\n  throw new Error(`${body.error} — available: ${body.available.join(', ')}`);\n}","preventionTips":["List available corpora before targeting one by name","Build the corpus as part of setup before any query/prime calls","URL-encode corpus names to avoid routing surprises","Handle 404 by offering the user the list from the response's 'available' field"],"tags":["http","rest","not-found"],"backgroundTag":"entity-not-found","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}