moeru-ai/airi · error · Error

The file is not an AIRI Live2D motion recording.

Error message

The file is not an AIRI Live2D motion recording.

What it means

After JSON parsing succeeds, parseLive2DMotionRecording validates the object against live2dMotionRecordingSchema with Valibot's safeParse. If the shape does not match the recording schema (wrong or missing fields, wrong types), the file is structurally not an AIRI Live2D motion recording and this error is thrown. It is deliberately generic so users know the file format itself is wrong, not just its content.

Source

Thrown at packages/stage-ui/src/features/devtools/motion/live2d/composables/recording.ts:92

/**
 * Parses and validates a Live2D joystick recording at the file boundary.
 *
 * @example
 * parseLive2DMotionRecording('{"format":"airi-live2d-motion/v6", ...}')
 * // => a validated recording
 */
export function parseLive2DMotionRecording(raw: string): Live2DMotionRecording {
  let input: unknown
  try {
    input = JSON.parse(raw)
  }
  catch {
    throw new Error('The file does not contain valid JSON.')
  }

  const result = safeParse(live2dMotionRecordingSchema, input)
  if (!result.success)
    throw new Error('The file is not an AIRI Live2D motion recording.')

  const { durationMs, samples } = result.output
  if (samples[0].atMs !== 0)
    throw new Error('The first motion sample must start at 0 ms.')

  for (let index = 1; index < samples.length; index++) {
    if (samples[index].atMs < samples[index - 1].atMs)
      throw new Error('The motion samples must be in time order.')
  }

  if (samples.at(-1)!.atMs > durationMs)
    throw new Error('A motion sample occurs after the recording duration.')

  return result.output
}

/**
 * Serializes a Live2D joystick recording as a readable JSON file.

View on GitHub (pinned to 9c213115f8)

Solutions

  1. Import a file produced by the AIRI Live2D motion recorder with the matching schema version
  2. Compare the file's top-level keys against live2dMotionRecordingSchema and fix missing/mistyped fields
  3. Upgrade/downgrade AIRI if the recording came from an incompatible version
  4. Inspect result.issues from safeParse to identify the exact schema mismatch

Example fix

// before
// { "frames": [...], "length": 3000 }
// after
// { "durationMs": 3000, "samples": [{ "atMs": 0, "values": { ... } }] }
Defensive patterns

Strategy: validation

Validate before calling

import { safeParse } from 'valibot'
import { live2dMotionRecordingSchema } from './schema'
const precheck = safeParse(live2dMotionRecordingSchema, JSON.parse(raw))
if (!precheck.success)
  console.error('Schema issues:', precheck.issues.map(i => `${i.path?.map(p => p.key).join('.')} ${i.message}`))

Type guard

const isMotionRecording = (v) =>
  typeof v === 'object' && v !== null
  && typeof v.durationMs === 'number'
  && Array.isArray(v.samples)
  && v.samples.every(s => typeof s.atMs === 'number' && typeof s.values === 'object')

Try / catch

try {
  const recording = parseLive2DMotionRecording(raw)
}
catch (error) {
  if (error.message === 'The file is not an AIRI Live2D motion recording.')
    showImportError('This file is not an AIRI Live2D motion recording. Export one from the motion recorder.')
  else throw error
}

Prevention

When it happens

Trigger: Calling parseLive2DMotionRecording on JSON that parses but lacks the schema-required fields (durationMs, samples with atMs/values) or has wrong types, e.g. samples as an object instead of an array, missing version fields, or a different AIRI export format.

Common situations: Importing a motion project JSON instead of a recording JSON; importing a recording from an older/newer schema version; hand-crafted files with missing required properties; exporting from a fork with a divergent schema.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of moeru-ai/airi@9c213115f8 (2026-09-02). Data as JSON: /api/errors/8b705f370ee08bd4. Report an issue: GitHub.