{"record":{"id":"aad94fbf42ebb2c4","repo":"chatboxai/chatbox","slug":"duplicate-resource-id-in-manifest-resource-id","errorCode":null,"errorMessage":"Duplicate resource id in manifest: ${resource.id}","messagePattern":"Duplicate resource id in manifest: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/renderer/packages/backup/types.ts","lineNumber":103,"sourceCode":"    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}`)\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) {","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/backup/types.ts#L85-L121","documentation":"Thrown while scanning manifest.resources: each resource entry needs a unique id because resources are stored and referenced by id during restore. A repeat aborts validation.","triggerScenarios":"Two entries in manifest.resources share the same resource.id.","commonSituations":"Resource list built without dedupe; merging backups; a deduplication step skipped during export.","solutions":["Remove or re-id the duplicate resource entry.","Re-run export with deduplication enabled.","When merging manifests, dedupe resources by id and remap session.resourceIds accordingly."],"exampleFix":"// before\nvalidateBackupManifestGraph(manifest)\n\n// after\nconst seen = new Set<string>()\nmanifest.resources = manifest.resources.filter((r) =>\n  seen.has(r.id) ? false : (seen.add(r.id), true)\n)","handlingStrategy":"validation","validationCode":"function findDuplicateResourceIds(manifest: BackupManifest): string[] {\n  const seen = new Set<string>()\n  const dups = new Set<string>()\n  for (const r of manifest.resources) (seen.has(r.id) ? dups : seen).add(r.id)\n  return [...dups]\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateBackupManifestGraph(manifest)\n} catch (error) {\n  if (/Duplicate resource id/.test((error as Error).message)) reportCorruptBackup(error)\n  throw error\n}","preventionTips":["Dedupe resources by id at export time.","When merging manifests, remap session.resourceIds after dedupe.","Always schema-parse before graph validation."],"tags":["backup","manifest","validation","dedupe"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}