{"record":{"id":"23cdf933013d0ac9","repo":"chatboxai/chatbox","slug":"session-contains-a-duplicate-resource-id-sessio","errorCode":null,"errorMessage":"Session contains a duplicate resource id: ${session.id}","messagePattern":"Session contains a duplicate resource id: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/renderer/packages/backup/types.ts","lineNumber":130,"sourceCode":"    const ownSessionIds = new Set<string>()\n    for (const sessionId of resource.sessionIds) {\n      if (ownSessionIds.has(sessionId)) throw new Error(`Resource contains a duplicate session id: ${resource.id}`)\n      ownSessionIds.add(sessionId)\n      if (!sessionIds.has(sessionId)) throw new Error(`Resource references an unknown session: ${sessionId}`)\n    }\n    if (resource.scope === 'session' && resource.sessionIds.length !== 1) {\n      throw new Error(`Session-scoped resource must reference exactly one session: ${resource.id}`)\n    }\n    if (resource.scope === 'global' && resource.sessionIds.length !== 0) {\n      throw new Error(`Global resource must not reference a session: ${resource.id}`)\n    }\n  }\n  const resourcesById = new Map(manifest.resources.map((resource) => [resource.id, resource]))\n  const sessionsById = new Map(manifest.sessions.map((session) => [session.id, session]))\n  for (const session of manifest.sessions) {\n    const ownResourceIds = new Set<string>()\n    for (const resourceId of session.resourceIds) {\n      if (ownResourceIds.has(resourceId)) throw new Error(`Session contains a duplicate resource id: ${session.id}`)\n      ownResourceIds.add(resourceId)\n      if (!resourceIds.has(resourceId)) throw new Error(`Session references an unknown resource: ${resourceId}`)\n      if (!resourcesById.get(resourceId)?.sessionIds.includes(session.id)) {\n        throw new Error(`Session/resource mapping is inconsistent: ${session.id}/${resourceId}`)\n      }\n    }\n  }\n  for (const resource of manifest.resources) {\n    for (const sessionId of resource.sessionIds) {\n      const session = sessionsById.get(sessionId)\n      if (!session?.resourceIds.includes(resource.id)) {\n        throw new Error(`Resource/session mapping is inconsistent: ${resource.id}/${sessionId}`)\n      }\n    }\n  }\n  if (\n    manifest.stats.sessionCount !== manifest.sessions.length ||\n    manifest.stats.resourceCount !== manifest.resources.length ||","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/backup/types.ts#L112-L148","documentation":"Thrown when a session's resourceIds array lists the same resource more than once. The session-to-resource link must be unique within a single session.","triggerScenarios":"session.resourceIds contains a repeated resourceId for one session entry.","commonSituations":"Exporter appended the same resource link twice; merge artifact; attachments concatenated without dedupe.","solutions":["Dedupe resourceIds within each session.","Re-export.","Audit the exporter's resource-attachment loop."],"exampleFix":"// before\nvalidateBackupManifestGraph(manifest)\n\n// after\nfor (const s of manifest.sessions) {\n  s.resourceIds = [...new Set(s.resourceIds)]\n}","handlingStrategy":"validation","validationCode":"function sessionsHaveUniqueResourceRefsLocally(manifest: BackupManifest): boolean {\n  return manifest.sessions.every((s) => new Set(s.resourceIds).size === s.resourceIds.length)\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateBackupManifestGraph(manifest)\n} catch (error) {\n  if (/Session contains a duplicate resource id/.test((error as Error).message)) dedupeSessionResourceIds(manifest)\n  throw error\n}","preventionTips":["Append resource links through a Set at export.","Re-validate after any session merge."],"tags":["backup","manifest","validation","dedupe"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}