{"record":{"id":"ede3de5b217a520a","repo":"thedotmack/claude-mem","slug":"validationerror-ede3de","errorCode":"ValidationError","errorMessage":"memory_items requires at least one searchable text field (narrative, text, title, subtitle, facts, or concepts) so the FTS index is populated; refusing to persist an empty record","messagePattern":"memory_items requires at least one searchable text field \\(narrative, text, title, subtitle, facts, or concepts\\) so the FTS index is populated; refusing to persist an empty record","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"src/server/routes/v1/ServerV1Routes.ts","lineNumber":191,"sourceCode":"      const event = new AgentEventsRepository(this.options.getDatabase()).getById(id);\n      if (!event) {\n        res.status(404).json({ error: 'NotFound', message: 'Event not found' });\n        return;\n      }\n      if (!this.ensureProjectAllowed(req, res, event.projectId)) return;\n      this.audit(req, 'event.read', event.id, event.projectId);\n      res.json({ event });\n    });\n\n    app.post('/v1/memories', writeAuth, this.handleCreate(CreateMemoryItemSchema, (req, res, body) => {\n      if (!this.ensureProjectAllowed(req, res, body.projectId)) return;\n      // Write-path contract (#2684/#2533): the FTS trigger (trg_memory_items_fts_insert)\n      // copies title/subtitle/text/narrative/facts/concepts into the search index.\n      // A row with NONE of the searchable text columns populated is invisible to\n      // search — it looks \"frozen\". Reject it LOUDLY here instead of silently\n      // persisting an unsearchable record.\n      if (!hasSearchableContent(body)) {\n        res.status(400).json({\n          error: 'ValidationError',\n          message: 'memory_items requires at least one searchable text field (narrative, text, title, subtitle, facts, or concepts) so the FTS index is populated; refusing to persist an empty record',\n        });\n        return;\n      }\n      const memory = new MemoryItemsRepository(this.options.getDatabase()).create(body);\n      this.audit(req, 'memory.write', memory.id, memory.projectId);\n      res.status(201).json({ memory });\n    }));\n\n    app.get('/v1/memories/:id', readAuth, (req, res) => {\n      const id = this.routeParam(req.params.id);\n      const memory = new MemoryItemsRepository(this.options.getDatabase()).getById(id);\n      if (!memory) {\n        res.status(404).json({ error: 'NotFound', message: 'Memory not found' });\n        return;\n      }\n      if (!this.ensureProjectAllowed(req, res, memory.projectId)) return;","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/server/routes/v1/ServerV1Routes.ts#L173-L209","documentation":"The memory_items create route enforces the write-path contract that every persisted memory item must populate at least one FTS-searchable text column (narrative, text, title, subtitle, facts, concepts). A body with none of these is rejected with 400 ValidationError because the FTS trigger would produce an empty index entry — an unsearchable ('invisible') record.","triggerScenarios":"POST /v1/memory-items with a body containing only metadata (ids, tags, timestamps) and none of narrative/text/title/subtitle/facts/concepts, or with all of them empty strings/empty arrays.","commonSituations":"Bulk importers syncing records that genuinely lack text (placeholder rows); refactors renaming a text field so the payload no longer matches the expected keys; clients sending { facts: [] } or title: '' assuming empties count as content.","solutions":["Include at least one non-empty searchable field — e.g. set narrative or text to a meaningful summary","If a record truly has no content, skip persisting it or store a synthetic title describing the absence","Check the payload keys match exactly the supported field names (typos silently yield 'no searchable content')"],"exampleFix":"// before\nawait client.createMemoryItem({ projectId, kind: 'note', tags: ['x'] }); // 400\n// after\nawait client.createMemoryItem({\n  projectId,\n  kind: 'note',\n  title: 'note',\n  narrative: 'Captured observation about X',\n  tags: ['x'],\n});","handlingStrategy":"validation","validationCode":"const SEARCHABLE = ['narrative', 'text', 'title', 'subtitle', 'facts', 'concepts'];\nfunction hasSearchableContent(item) {\n  return SEARCHABLE.some(k => {\n    const v = item[k];\n    return typeof v === 'string' ? v.trim().length > 0 : Array.isArray(v) && v.length > 0;\n  });\n}\nif (!hasSearchableContent(body)) throw new Error('memory item needs a searchable text field');","typeGuard":"function isPersistableMemoryItem(b) {\n  return ['narrative','text','title','subtitle','facts','concepts'].some(k => b[k] != null && b[k].length > 0);\n}","tryCatchPattern":"try { await client.createMemoryItem(body); }\ncatch (e) {\n  if (e.status === 400 && /searchable text field/.test(e.message ?? '')) {\n    return client.createMemoryItem({ ...body, narrative: body.narrative || '(no content)' });\n  }\n  throw e;\n}","preventionTips":["Always populate title or narrative, even for metadata-only records","Validate payloads with hasSearchableContent before sending","Watch for key renames in clients that silently empty the text fields"],"tags":["validation","http-400","fts","search","empty-payload"],"backgroundTag":"empty-required-field","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"}