chatboxai/chatbox · error

Resource contains a duplicate session id: ${resource.id}

Error message

Resource contains a duplicate session id: ${resource.id}

What it means

Thrown when one resource's sessionIds array lists the same session more than once. A resource-to-session link must be unique within a single resource.

Source

Thrown at src/renderer/packages/backup/types.ts:114

  const sessionIds = new Set<string>()
  for (const session of manifest.sessions) {
    if (sessionIds.has(session.id)) throw new Error(`Duplicate session id in manifest: ${session.id}`)
    sessionIds.add(session.id)
    if (session.meta.id !== session.id) throw new Error(`Session metadata id does not match: ${session.id}`)
  }
  for (const resource of manifest.resources) {
    if (resourceIds.has(resource.id)) throw new Error(`Duplicate resource id in manifest: ${resource.id}`)
    resourceIds.add(resource.id)
    const ownResourceKeys = new Set<string>()
    for (const key of resource.originalStorageKeys) {
      if (ownResourceKeys.has(key)) throw new Error(`Resource contains a duplicate storage key: ${resource.id}`)
      ownResourceKeys.add(key)
      if (resourceKeys.has(key)) throw new Error(`Duplicate resource storage key in manifest: ${key}`)
      resourceKeys.add(key)
    }
    const ownSessionIds = new Set<string>()
    for (const sessionId of resource.sessionIds) {
      if (ownSessionIds.has(sessionId)) throw new Error(`Resource contains a duplicate session id: ${resource.id}`)
      ownSessionIds.add(sessionId)
      if (!sessionIds.has(sessionId)) throw new Error(`Resource references an unknown session: ${sessionId}`)
    }
    if (resource.scope === 'session' && resource.sessionIds.length !== 1) {
      throw new Error(`Session-scoped resource must reference exactly one session: ${resource.id}`)
    }
    if (resource.scope === 'global' && resource.sessionIds.length !== 0) {
      throw new Error(`Global resource must not reference a session: ${resource.id}`)
    }
  }
  const resourcesById = new Map(manifest.resources.map((resource) => [resource.id, resource]))
  const sessionsById = new Map(manifest.sessions.map((session) => [session.id, session]))
  for (const session of manifest.sessions) {
    const ownResourceIds = new Set<string>()
    for (const resourceId of session.resourceIds) {
      if (ownResourceIds.has(resourceId)) throw new Error(`Session contains a duplicate resource id: ${session.id}`)
      ownResourceIds.add(resourceId)
      if (!resourceIds.has(resourceId)) throw new Error(`Session references an unknown resource: ${resourceId}`)

View on GitHub (pinned to 81571269ad)

Solutions

  1. Dedupe sessionIds within each resource.
  2. Re-export.
  3. Audit the exporter's session-attachment loop.

Example fix

// before
validateBackupManifestGraph(manifest)

// after
for (const r of manifest.resources) {
  r.sessionIds = [...new Set(r.sessionIds)]
}
Defensive patterns

Strategy: validation

Validate before calling

function resourcesHaveUniqueSessionRefsLocally(manifest: BackupManifest): boolean {
  return manifest.resources.every((r) => new Set(r.sessionIds).size === r.sessionIds.length)
}

Try / catch

try {
  validateBackupManifestGraph(manifest)
} catch (error) {
  if (/duplicate session id/.test((error as Error).message)) dedupeResourceSessionIds(manifest)
  throw error
}

Prevention

When it happens

Trigger: resource.sessionIds contains a repeated sessionId for a single resource entry.

Common situations: Exporter appended the same session link twice; merge artifact; attachments concatenated without dedupe.

Related errors


AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12). Data as JSON: /api/errors/5eda99621f60f224. Report an issue: GitHub.