{"record":{"id":"329d156b4d5ca43e","repo":"chatboxai/chatbox","slug":"resource-session-mapping-is-inconsistent-resour","errorCode":null,"errorMessage":"Resource/session mapping is inconsistent: ${resource.id}/${sessionId}","messagePattern":"Resource/session mapping is inconsistent: (.+?)/(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/renderer/packages/backup/types.ts","lineNumber":142,"sourceCode":"  }\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 ||\n    manifest.stats.warningCount !== manifest.warnings.length\n  ) {\n    throw new Error('Backup manifest statistics do not match its entries')\n  }\n}\n\nexport interface BackupProgress {\n  phase: 'preparing' | 'sessions' | 'resources' | 'packing' | 'reading' | 'validating' | 'restoring'\n  current: number\n  total: number\n  label?: string\n}","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/backup/types.ts#L124-L160","documentation":"Thrown for the reverse-link mismatch: resource R lists session S, but S.resourceIds does not include R. This is the symmetric counterpart to error 152 and catches resources that claim a session which doesn't claim them back.","triggerScenarios":"sessionsById.get(sessionId).resourceIds does not include resource.id, even though resource.sessionIds includes sessionId.","commonSituations":"A bidirectional link edited on one side only; exporter inconsistency; a partial repair.","solutions":["Add resource.id to the session's resourceIds.","Or remove sessionId from the resource's sessionIds if the link is spurious.","Re-export to regenerate both directions."],"exampleFix":"// before\n// resource->session link exists, but session->resource does not\n\n// after\nconst sessionsById = new Map(manifest.sessions.map((s) => [s.id, s]))\nfor (const r of manifest.resources) {\n  for (const sid of r.sessionIds) {\n    const s = sessionsById.get(sid)\n    if (s && !s.resourceIds.includes(r.id)) s.resourceIds.push(r.id)\n  }\n}","handlingStrategy":"try-catch","validationCode":"function reverseLinksAreSymmetric(manifest: BackupManifest): boolean {\n  const sessionsById = new Map(manifest.sessions.map((s) => [s.id, s]))\n  return manifest.resources.every((r) =>\n    r.sessionIds.every((sid) => sessionsById.get(sid)?.resourceIds.includes(r.id))\n  )\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateBackupManifestGraph(manifest)\n} catch (error) {\n  if (/Resource\\/session mapping is inconsistent/.test((error as Error).message)) symmetrizeLinks(manifest)\n  throw error\n}","preventionTips":["Write both directions of every link in the same exporter code path.","Re-validate after any link edit on either side.","Avoid manual manifest edits; regenerate instead."],"tags":["backup","manifest","validation","referential-integrity"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}