chatboxai/chatbox · error

Duplicate resource id in manifest: ${resource.id}

Error message

Duplicate resource id in manifest: ${resource.id}

What it means

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.

Source

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

    sessionCount: z.number().int().nonnegative(),
    resourceCount: z.number().int().nonnegative(),
    deduplicatedResourceCount: z.number().int().nonnegative(),
    warningCount: z.number().int().nonnegative(),
  }),
})
export type BackupManifest = z.infer<typeof BackupManifestSchema>

export function validateBackupManifestGraph(manifest: BackupManifest): void {
  const resourceIds = new Set<string>()
  const resourceKeys = new Set<string>()
  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) {

View on GitHub (pinned to 81571269ad)

Solutions

  1. Remove or re-id the duplicate resource entry.
  2. Re-run export with deduplication enabled.
  3. When merging manifests, dedupe resources by id and remap session.resourceIds accordingly.

Example fix

// before
validateBackupManifestGraph(manifest)

// after
const seen = new Set<string>()
manifest.resources = manifest.resources.filter((r) =>
  seen.has(r.id) ? false : (seen.add(r.id), true)
)
Defensive patterns

Strategy: validation

Validate before calling

function findDuplicateResourceIds(manifest: BackupManifest): string[] {
  const seen = new Set<string>()
  const dups = new Set<string>()
  for (const r of manifest.resources) (seen.has(r.id) ? dups : seen).add(r.id)
  return [...dups]
}

Try / catch

try {
  validateBackupManifestGraph(manifest)
} catch (error) {
  if (/Duplicate resource id/.test((error as Error).message)) reportCorruptBackup(error)
  throw error
}

Prevention

When it happens

Trigger: Two entries in manifest.resources share the same resource.id.

Common situations: Resource list built without dedupe; merging backups; a deduplication step skipped during export.

Related errors


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