{"record":{"id":"60b3a2e97a60c1f3","repo":"thedotmack/claude-mem","slug":"session-summary-source-id-must-equal-server-sessio","errorCode":null,"errorMessage":"session_summary source_id must equal server_session_id","messagePattern":"session_summary source_id must equal server_session_id","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/storage/postgres/generation-jobs.ts","lineNumber":285,"sourceCode":"        [eventId, input.projectId, input.teamId]\n      );\n      if (!row || input.sourceId !== eventId) {\n        throw new Error('agent_event source_id must belong to project_id and team_id');\n      }\n      if (input.serverSessionId) {\n        await assertSessionOwnership(this.client, input.serverSessionId, input.projectId, input.teamId);\n        if (row.server_session_id && row.server_session_id !== input.serverSessionId) {\n          throw new Error('server_session_id must match the agent_event server_session_id');\n        }\n      }\n      return;\n    }\n\n    if (input.sourceType === 'session_summary') {\n      const sessionId = input.serverSessionId ?? input.sourceId;\n      await assertSessionOwnership(this.client, sessionId, input.projectId, input.teamId);\n      if (input.sourceId !== sessionId) {\n        throw new Error('session_summary source_id must equal server_session_id');\n      }\n      return;\n    }\n\n    const observation = await queryOne<{ id: string }>(\n      this.client,\n      'SELECT id FROM observations WHERE id = $1 AND project_id = $2 AND team_id = $3',\n      [input.sourceId, input.projectId, input.teamId]\n    );\n    if (!observation) {\n      throw new Error('observation_reindex source_id must belong to project_id and team_id');\n    }\n    if (input.serverSessionId) {\n      await assertSessionOwnership(this.client, input.serverSessionId, input.projectId, input.teamId);\n    }\n  }\n}\n","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/storage/postgres/generation-jobs.ts#L267-L303","documentation":"For sourceType 'session_summary', validateSource requires that sourceId equals the effective session id (input.serverSessionId if given, otherwise sourceId itself), and that session ownership over project/team is asserted. Thrown when the caller supplies a sourceId that does not match the server_session_id being used.","triggerScenarios":"create() with sourceType 'session_summary' where sourceId !== (serverSessionId ?? sourceId) — i.e. both serverSessionId and sourceId are set and differ, or sourceId is not a valid server session id owned by the project/team.","commonSituations":"Caller passes an observation or summary id as sourceId instead of the session id; copying serverSessionId from a different conversation; typos or truncated session uuids in API payloads.","solutions":["Set sourceId to the server session id the summary belongs to","Remove the separate serverSessionId field or make it identical to sourceId","Verify the session exists under the same project_id and team_id via an ownership check before calling","Regenerate the summary if the original session was deleted"],"exampleFix":"// before\nawait jobs.create({ sourceType: 'session_summary', sourceId: summaryId, serverSessionId: sessionId });\n// after\nawait jobs.create({ sourceType: 'session_summary', sourceId: sessionId, serverSessionId: sessionId });","handlingStrategy":"validation","validationCode":"if (input.sourceType === 'session_summary' && input.serverSessionId && input.sourceId !== input.serverSessionId) {\n  throw new Error('session_summary sourceId must equal serverSessionId');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await jobs.create(input);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('session_summary source_id must equal')) {\n    await jobs.create({ ...input, sourceId: input.serverSessionId ?? input.sourceId });\n  } else throw err;\n}","preventionTips":["Pass the session id as sourceId for session_summary jobs","Never pass a summary/observation id as sourceId for this source type","Validate equality of sourceId and serverSessionId in your request DTO layer"],"tags":["postgres","validation","session"],"backgroundTag":"invalid-argument-value","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"}