{"record":{"id":"638900b51194799f","repo":"chatboxai/chatbox","slug":"global-resource-must-not-reference-a-session-re","errorCode":null,"errorMessage":"Global resource must not reference a session: ${resource.id}","messagePattern":"Global resource must not reference a session: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/renderer/packages/backup/types.ts","lineNumber":122,"sourceCode":"    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) {\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)","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/backup/types.ts#L104-L140","documentation":"Thrown when a resource has scope 'global' but references one or more sessions. Global resources must be session-agnostic, so any sessionId entry is invalid.","triggerScenarios":"resource.scope === 'global' and resource.sessionIds.length !== 0.","commonSituations":"A previously session-scoped resource was promoted to global without clearing its links; exporter didn't clear sessionIds on global promotion.","solutions":["Clear resource.sessionIds to [] if the resource is truly global.","Change scope to 'shared' if the session links are intentional.","Re-export."],"exampleFix":"// before\n// scope 'global' but sessionIds is non-empty\n\n// after\nfor (const r of manifest.resources) {\n  if (r.scope === 'global') r.sessionIds = []\n}","handlingStrategy":"validation","validationCode":"function globalResourcesAreUnscoped(manifest: BackupManifest): boolean {\n  return manifest.resources.every((r) => r.scope !== 'global' || r.sessionIds.length === 0)\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateBackupManifestGraph(manifest)\n} catch (error) {\n  if (/Global resource must not/.test((error as Error).message)) clearGlobalSessionRefs(manifest)\n  throw error\n}","preventionTips":["Clear sessionIds when promoting a resource to scope 'global'.","Treat scope and sessionIds as a single unit at export."],"tags":["backup","manifest","validation","scope"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}