{"record":{"id":"260e5cca35247b9a","repo":"chatboxai/chatbox","slug":"duplicate-session-id-in-manifest-session-id","errorCode":null,"errorMessage":"Duplicate session id in manifest: ${session.id}","messagePattern":"Duplicate session id in manifest: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/renderer/packages/backup/types.ts","lineNumber":98,"sourceCode":"  }),\n  sessions: z.array(BackupSessionEntrySchema).max(50_000),\n  resources: z.array(BackupResourceEntrySchema).max(50_000),\n  warnings: z.array(BackupWarningSchema).max(50_000),\n  stats: z.object({\n    sessionCount: z.number().int().nonnegative(),\n    resourceCount: z.number().int().nonnegative(),\n    deduplicatedResourceCount: z.number().int().nonnegative(),\n    warningCount: z.number().int().nonnegative(),\n  }),\n})\nexport type BackupManifest = z.infer<typeof BackupManifestSchema>\n\nexport function validateBackupManifestGraph(manifest: BackupManifest): void {\n  const resourceIds = new Set<string>()\n  const resourceKeys = new Set<string>()\n  const sessionIds = new Set<string>()\n  for (const session of manifest.sessions) {\n    if (sessionIds.has(session.id)) throw new Error(`Duplicate session id in manifest: ${session.id}`)\n    sessionIds.add(session.id)\n    if (session.meta.id !== session.id) throw new Error(`Session metadata id does not match: ${session.id}`)\n  }\n  for (const resource of manifest.resources) {\n    if (resourceIds.has(resource.id)) throw new Error(`Duplicate resource id in manifest: ${resource.id}`)\n    resourceIds.add(resource.id)\n    const ownResourceKeys = new Set<string>()\n    for (const key of resource.originalStorageKeys) {\n      if (ownResourceKeys.has(key)) throw new Error(`Resource contains a duplicate storage key: ${resource.id}`)\n      ownResourceKeys.add(key)\n      if (resourceKeys.has(key)) throw new Error(`Duplicate resource storage key in manifest: ${key}`)\n      resourceKeys.add(key)\n    }\n    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}`)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/backup/types.ts#L80-L116","documentation":"Thrown by validateBackupManifestGraph while scanning manifest.sessions. Each session entry must carry a unique id; when a second session with an already-seen id is found, validation aborts. This protects the restore path, which keys session storage by id.","triggerScenarios":"Two entries in manifest.sessions share the same session.id. Produced by a hand-edited manifest, a merge of two exports, or an exporter that failed to dedupe by id.","commonSituations":"Merging two backup files; exporting a session list with a duplicated row; a sync collision that wrote the same session id twice.","solutions":["Inspect manifest.sessions and remove or rename the duplicate id entry.","Re-export from the source so the exporter dedupes by id.","When merging backups, dedupe sessions by id before packing the manifest."],"exampleFix":"// before\nvalidateBackupManifestGraph(manifest)\n\n// after\nconst seen = new Set<string>()\nmanifest.sessions = manifest.sessions.filter((s) =>\n  seen.has(s.id) ? false : (seen.add(s.id), true)\n)\nvalidateBackupManifestGraph(manifest)","handlingStrategy":"validation","validationCode":"function findDuplicateSessionIds(manifest: BackupManifest): string[] {\n  const seen = new Set<string>()\n  const dups = new Set<string>()\n  for (const s of manifest.sessions) (seen.has(s.id) ? dups : seen).add(s.id)\n  return [...dups]\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateBackupManifestGraph(manifest)\n} catch (error) {\n  if (/Duplicate session id/.test((error as Error).message)) reportCorruptBackup(error)\n  throw error\n}","preventionTips":["Always run BackupManifestSchema.parse before validateBackupManifestGraph.","Dedupe sessions by id at export time.","Never hand-merge manifests without re-validating."],"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"}