{"record":{"id":"42a384393683c809","repo":"thedotmack/claude-mem","slug":"validationerror-42a384","errorCode":"ValidationError","errorMessage":"ValidationError","messagePattern":"ValidationError","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"src/server/compat/SessionsSummarizeAdapter.ts","lineNumber":53,"sourceCode":"  endSession: EndSessionService;\n  authMode?: string;\n  allowLocalDevBypass?: boolean;\n}\n\nexport class SessionsSummarizeAdapter implements RouteHandler {\n  constructor(private readonly options: SessionsSummarizeAdapterOptions) {}\n\n  setupRoutes(app: Application): void {\n    const writeAuth = requirePostgresServerAuth(this.options.pool, {\n      authMode: this.options.authMode,\n      allowLocalDevBypass: this.options.allowLocalDevBypass,\n      requiredScopes: ['memories:write'],\n    });\n\n    app.post('/api/sessions/summarize', writeAuth, this.asyncHandler(async (req, res) => {\n      const parsed = summarizeSchema.safeParse(req.body);\n      if (!parsed.success) {\n        res.status(400).json({ error: 'ValidationError', issues: parsed.error.issues });\n        return;\n      }\n      const teamId = req.authContext?.teamId ?? null;\n      const projectId = req.authContext?.projectId ?? null;\n      if (!teamId) {\n        res.status(403).json({ error: 'Forbidden', message: 'API key is not bound to a team' });\n        return;\n      }\n      if (!projectId) {\n        res.status(400).json({\n          error: 'BadRequest',\n          message: 'Legacy /api/sessions/summarize requires a project-scoped API key',\n        });\n        return;\n      }\n\n      // Subagent contexts in legacy code emit summarize calls but the worker\n      // skipped them. We preserve the legacy semantics so existing clients","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/server/compat/SessionsSummarizeAdapter.ts#L35-L71","documentation":"The legacy /api/sessions/summarize compat route validates req.body against summarizeSchema with safeParse and returns HTTP 400 { error:'ValidationError', issues:[...] } when the payload does not match. This is the adapter's input-contract enforcement before any ingestion happens.","triggerScenarios":"POST /api/sessions/summarize with a body missing required fields (e.g. contentSessionId) or with wrong types, per summarizeSchema in SessionsSummarizeAdapter.ts.","commonSituations":"Older Claude Code clients sending a payload shape that drifted from the current summarizeSchema; manual curl testing with incomplete JSON; client bug after a schema field was renamed or made required.","solutions":["Read the issues array in the 400 response — it lists exact failing paths and expected types","Align the client payload with summarizeSchema (required fields and types)","If the schema changed, update the legacy client or relax/extend the schema in the adapter","Test the payload with a quick safeParse in a script before calling the endpoint"],"exampleFix":"// before\nawait fetch('/api/sessions/summarize', { method: 'POST', body: JSON.stringify({}) });\n// after\nawait fetch('/api/sessions/summarize', { method: 'POST', body: JSON.stringify({ contentSessionId: 'sess_123' }) });","handlingStrategy":"validation","validationCode":"// mirror summarizeSchema on the client before POSTing\nimport { summarizeSchema } from './schemas';\nconst parsed = summarizeSchema.safeParse(body);\nif (!parsed.success) throw new Error(`Invalid summarize payload: ${JSON.stringify(parsed.error.issues)}`);","typeGuard":"const isValidSummarizeBody = (b) => typeof b?.contentSessionId === 'string' && b.contentSessionId.length > 0;","tryCatchPattern":"// handle 400 validation errors explicitly\nif (res.status === 400 && body.error === 'ValidationError') {\n  console.error('Payload rejected:', body.issues);\n}","preventionTips":["Generate the client payload types from the shared zod schema","Validate payloads in CI with the same schema the server uses","Pin client versions against server schema changes and read the issues array on failure"],"tags":["http","validation","zod","compat"],"backgroundTag":"schema-validation-failed","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"}