chatboxai/chatbox · error

Session metadata id does not match: ${session.id}

Error message

Session metadata id does not match: ${session.id}

What it means

Thrown when a session entry's id disagrees with its nested meta.id. The manifest stores the id both on the entry shell and inside the SessionMetaRecord; they must agree so restore can match metadata to the session's stored bytes.

Source

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

  resources: z.array(BackupResourceEntrySchema).max(50_000),
  warnings: z.array(BackupWarningSchema).max(50_000),
  stats: z.object({
    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) {

View on GitHub (pinned to 81571269ad)

Solutions

  1. Reconcile session.id and session.meta.id so they are identical.
  2. Re-export the affected session from the source.
  3. If repairing deliberately, set session.meta.id = session.id (or vice versa) and keep one source of truth.

Example fix

// before
// manifest has session.id !== session.meta.id

// after
for (const session of manifest.sessions) {
  session.meta = { ...session.meta, id: session.id }
}
Defensive patterns

Strategy: validation

Validate before calling

function sessionIdsMatch(manifest: BackupManifest): boolean {
  return manifest.sessions.every((s) => s.meta.id === s.id)
}

Try / catch

try {
  validateBackupManifestGraph(manifest)
} catch (error) {
  if (/metadata id does not match/.test((error as Error).message)) attemptSessionRepair(manifest)
  throw error
}

Prevention

When it happens

Trigger: session.id !== session.meta.id — e.g. a session was copied and its shell id changed but meta.id wasn't, or metadata payloads were swapped between sessions during editing.

Common situations: Manual manifest editing; copy-pasting session entries; an exporter bug that writes the wrong meta payload.

Related errors


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