moeru-ai/airi · error · Error

Invalid chat session export format

Error message

Invalid chat session export format

What it means

Thrown by importChatSessions() when the parsed JSON payload's top-level `format` field does not equal the literal 'chat-sessions-index:v1'. This is a structural guard: AIRI's chat-session export format is versioned with that magic string, and the importer refuses anything else before touching the session store. It protects importSessions() from foreign or stale-shape data.

Source

Thrown at packages/stage-ui/src/composables/use-data-maintenance.ts:85

  function deleteAllChatSessions() {
    chatOrchestrator.cancelPendingSends()
    chatStore.resetAllSessions()
  }

  async function exportChatSessions() {
    const data = await chatStore.exportSessions()
    return new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' })
  }

  function isChatSessionsPayload(payload: unknown): payload is ChatSessionsExport {
    if (!payload || typeof payload !== 'object')
      return false
    return (payload as { format?: string }).format === 'chat-sessions-index:v1'
  }

  async function importChatSessions(payload: Record<string, unknown>) {
    if (!isChatSessionsPayload(payload))
      throw new Error('Invalid chat session export format')
    await chatStore.importSessions(payload)
    return payload
  }

  async function resetSettingsState() {
    await settingsStore.resetState()
    audioSettingsStore.resetState()
    live2dParamsStore.resetState()
    live2dSettingsStore.resetState()
    threeStore.resetModelStore()
    mcpStore.resetState()
    onboardingStore.resetSetupState()
    airiCardStore.resetState()
  }

  async function deleteAllData() {
    await deleteAllModels()
    await resetProvidersSettings()

View on GitHub (pinned to 27111382b4)

Solutions

  1. Re-export chat sessions from AIRI via exportChatSessions() and import that file — its format field is always 'chat-sessions-index:v1'.
  2. If importing an older export, open the JSON and set the top-level `format` field to 'chat-sessions-index:v1' only if the rest of the shape matches ChatSessionsExport; otherwise upgrade by re-exporting.
  3. Verify the file was produced by this AIRI version and not corrupted: confirm `payload.format === 'chat-sessions-index:v1'` in a console before importing.

Example fix

// before: importing arbitrary JSON
await importChatSessions(parsed)
// after: guard before calling
if (!parsed || parsed.format !== 'chat-sessions-index:v1') {
  throw new Error(`Expected chat-sessions-index:v1, got ${parsed?.format ?? 'none'}`)
}
await importChatSessions(parsed)
Defensive patterns

Strategy: type-guard

Validate before calling

function isChatSessionsExport(payload: unknown): payload is { format: string } {
  return !!payload && typeof payload === 'object'
    && (payload as { format?: unknown }).format === 'chat-sessions-index:v1'
}
// run before importChatSessions:
const parsed = JSON.parse(text)
if (!isChatSessionsExport(parsed)) {
  throw new Error(`Refusing import: expected format 'chat-sessions-index:v1', got ${(parsed as any)?.format}`)
}

Type guard

function isChatSessionsPayload(payload: unknown): payload is ChatSessionsExport {
  if (!payload || typeof payload !== 'object')
    return false
  return (payload as { format?: string }).format === 'chat-sessions-index:v1'
}

Try / catch

try {
  await importChatSessions(parsed)
}
catch (err) {
  if (err instanceof Error && err.message === 'Invalid chat session export format') {
    // show user-facing 'wrong file' message; do not retry with same payload
  }
  else throw err
}

Prevention

When it happens

Trigger: Calling importChatSessions() with a JSON object whose `format` field is missing, undefined, or a different value (e.g. an older export tagged 'chat-sessions:v0', a hand-edited file, or an unrelated JSON document). The type guard isChatSessionsPayload() returns false and the throw fires before chatStore.importSessions runs.

Common situations: User picks the wrong file in the import dialog (e.g. a settings export or arbitrary JSON). The file is an export from an older AIRI version that used a different format tag. The file was renamed/tampered with so the format field was stripped.

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/564acd6f7ad23833. Report an issue: GitHub.