{"record":{"id":"046950074d865b64","repo":"thedotmack/claude-mem","slug":"error","errorCode":"error","errorMessage":"internal_error","messagePattern":"internal_error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"src/server/compat/SessionsSummarizeAdapter.ts","lineNumber":85,"sourceCode":"        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\n      // see the same response shape.\n      if (parsed.data.agentId) {\n        res.json({ status: 'skipped', reason: 'subagent_context' });\n        return;\n      }\n\n      try {\n        await this.summarizeSession(req, res, parsed.data, teamId, projectId);\n      } catch (error) {\n        logger.error('SYSTEM', 'compat summarize adapter failed', {\n          error: error instanceof Error ? error.message : String(error),\n          contentSessionId: parsed.data.contentSessionId,\n        });\n        res.status(500).json({ status: 'error', reason: 'internal_error' });\n      }\n    }));\n  }\n\n  private async summarizeSession(\n    req: Request,\n    res: Response,\n    data: z.infer<typeof summarizeSchema>,\n    teamId: string,\n    projectId: string,\n  ): Promise<void> {\n    const platformSource = normalizePlatformSource(\n      typeof data.platformSource === 'string'\n        ? data.platformSource\n        : DEFAULT_PLATFORM_SOURCE,\n    );\n    const session = await resolveServerSession({\n      pool: this.options.pool,","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/server/compat/SessionsSummarizeAdapter.ts#L67-L103","documentation":"The compat summarize adapter wraps summarizeSession in try/catch and returns HTTP 500 { status:'error', reason:'internal_error' } for any unexpected failure during the summarize/ingest pipeline. The specific cause is only in the server logs under 'compat summarize adapter failed'.","triggerScenarios":"Any exception thrown inside summarizeSession — database write failure, IngestEventsService/summarize service rejection, unexpected null in the parsed payload — after validation and auth checks pass.","commonSituations":"DB outages or migration drift; summarize service dependency failure (e.g. summarizer queue down); regressions in the compat translation layer after refactors.","solutions":["Check server logs for 'compat summarize adapter failed' to identify the real exception","Retry after verifying database and summarize-service health","Inspect the payload for null fields (contentSessionId) that may crash downstream code","Add explicit error mapping in the adapter instead of the blanket catch"],"exampleFix":"// server log\n// before: { status:'error', reason:'internal_error' }\n// after: include stack and payload in the log line\nlogger.error('SYSTEM', 'compat summarize adapter failed', { error: err.message, stack: err.stack, payload: parsed.data });","handlingStrategy":"retry","validationCode":"if (!payload.contentSessionId) throw new Error('contentSessionId required before summarize');","typeGuard":"const hasSessionId = (p) => typeof p?.contentSessionId === 'string' && p.contentSessionId.length > 0;","tryCatchPattern":"// retry transient 500s, escalate persistent ones\nif (res.status === 500 && body.reason === 'internal_error') {\n  if (attempt < 3) return retryWithBackoff(attempt + 1);\n  throw new Error(`Summarize failed persistently: ${await res.text()}`);\n}","preventionTips":["Alert on 'compat summarize adapter failed' log entries","Verify DB and summarize-service health checks pass before deploys","Log the underlying error stack inside the adapter catch block","Add end-to-end tests for the summarize compat path"],"tags":["http","internal-error","compat","summarize"],"backgroundTag":"internal-invariant-violation","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"}