moeru-ai/airi · error · Error

The motion sequence must contain at least one value.

Error message

The motion sequence must contain at least one value.

What it means

VAR fitting needs at least one frame with at least one value per frame; an empty `sequence.frames` array or frames of length 0 have nothing to model. The check runs before any matrix construction so failures are immediate and clear.

Source

Thrown at packages/motion-driver-magic/src/shared/var.ts:79

  const residuals: number[][] = []
  for (let frameIndex = order; frameIndex < frames.length; frameIndex++) {
    const feature = createAutoregressiveFeature(frames, order, channelCount, frameIndex)
    const prediction = predictAutoregressiveValues(coefficients, feature)
    residuals.push(frames[frameIndex].map((value, channel) => value - prediction[channel]))
  }
  return residuals
}

/** Fits the VAR parameters that both public methods use. */
export function fitVarParameters(sequence: TrainingSequence, options: VarFitOptions): VarParameters {
  if (!Number.isFinite(sequence.sampleRateHz) || sequence.sampleRateHz <= 0)
    throw new Error('The motion sample rate must be positive.')
  if (options.order < 1 || !Number.isInteger(options.order))
    throw new Error('The VAR order must be a positive integer.')

  const frames = sequence.frames
  if (frames.length === 0 || frames[0].length === 0)
    throw new Error('The motion sequence must contain at least one value.')
  if (frames.some(frame => frame.length !== frames[0].length))
    throw new Error('Every motion frame must have the same number of values.')

  const channels = createMotionChannels(frames)
  if (channels.length === 0)
    throw new Error('The current motion has no changing channels.')
  if (frames.length <= options.order + 1)
    throw new Error('The current motion is too short for this VAR order.')

  const baselineFrame = createBaselineFrame(frames)
  const trainingFrames = frames.map(frame => channels.map(
    channel => (frame[channel.valueIndices[0]] - channel.mean) / channel.scale,
  ))
  const coefficients = fitCoefficients(trainingFrames, options)
  const residuals = createResiduals(trainingFrames, coefficients, options.order)
  const squaredResidualSum = residuals.reduce(
    (sum, residual) => sum + residual.reduce((channelSum, value) => channelSum + value ** 2, 0),
    0,

View on GitHub (pinned to 9c213115f8)

Solutions

  1. Verify the recording actually captured frames before fitting; check `frames.length` upstream.
  2. Fix the slicing/filtering logic that emptied the frame list.
  3. Reject empty sequences at the ingestion boundary with your own clearer message.
  4. Ensure the capture pipeline (device open -> frame callback -> buffer) ran end-to-end before training.

Example fix

// before
fitVarParameters({ frames: recorded, sampleRateHz: 30 }, opts)
// after
if (recorded.length === 0 || recorded[0].length === 0)
  throw new Error('No motion frames captured')
fitVarParameters({ frames: recorded, sampleRateHz: 30 }, opts)
Defensive patterns

Strategy: validation

Validate before calling

function hasFrames(seq: TrainingSequence): boolean {
  return seq.frames.length > 0 && seq.frames[0].length > 0
}

Try / catch

try {
  fitVarParameters(seq, options)
} catch (error) {
  if (error instanceof Error && error.message.includes('at least one value')) {
    console.error('Empty motion sequence; check the capture pipeline')
    return null
  }
  throw error
}

Prevention

When it happens

Trigger: Passing a TrainingSequence with `frames: []`, or `frames: [[]]` — e.g. a recording that captured zero frames, a filter that removed all frames, or a channel-selection step that dropped every value.

Common situations: Recording started after capture stopped (empty buffer); upstream filtering dropped everything (all frames below a threshold); deserializing a saved motion file that failed partially; slicing a frame range with wrong indices producing empty arrays.

Related errors


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