moeru-ai/airi · error · Error
Every motion frame must have the same number of values.
Error message
Every motion frame must have the same number of values.
What it means
fitVarParameters fits vector-autoregressive parameters to a motion sequence, treating each column of the frame matrix as a channel. It requires a rectangular frame matrix; every frame must supply the same number of scalar values. It throws this error when any frame's length differs from the first frame's length, because ragged input would silently misalign channels.
Source
Thrown at packages/motion-driver-magic/src/shared/var.ts:81
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
- Inspect sequence.frames and find frames whose .length differs from frames[0].length; correct or drop them
- Normalize all frames through the same extraction pipeline so each frame maps to the same fixed set of values
- Pad or trim frames to a fixed dimensionality before fitting (documenting which values are padded)
- Add a validation step upstream that rejects ragged frame matrices before calling fitVarParameters
Example fix
// before
const frames = [[0, 1, 2], [0, 1]] // ragged
fitVarParameters({ frames, ... }, options)
// after
const frames = [[0, 1, 2], [3, 4, 5]] // all frames same length
fitVarParameters({ frames, ... }, options) Defensive patterns
Strategy: validation
Validate before calling
function isRectangular(frames: number[][]): boolean {
return frames.length > 0 && frames.every(f => f.length === frames[0].length)
}
if (!isRectangular(sequence.frames)) throw new Error('Frames must all have the same length') Type guard
function isNumberMatrix(v: unknown): v is number[][] {
return Array.isArray(v) && v.length > 0 && v.every(f => Array.isArray(f) && f.length === v[0].length && f.every(n => typeof n === 'number'))
} Try / catch
try {
const params = fitVarParameters(sequence, options)
} catch (e) {
if (e instanceof Error && e.message === 'Every motion frame must have the same number of values.') {
// report which frame lengths are present and resample/repair
} else throw e
} Prevention
- Build frames through a single extraction function that always emits a fixed-length vector
- Assert frame dimensionality in tests for every motion source you ingest
- Log frames.filter(f => f.length !== frames[0].length).length in preprocessing pipelines
- Reject ragged clips at import time instead of at fit time
When it happens
Trigger: Calling fitVarParameters (directly or via sourceModel/parameters) with a sequence whose frames array contains arrays of differing lengths, e.g. mixing poses with different joint counts or appending a partial frame.
Common situations: Importing motion data from heterogeneous sources where some frames carry extra or missing channels; concatenating clips recorded with different skeletons; hand-building test sequences with typos in frame lengths.
Related errors
- The current motion has no changing channels.
- The current motion is too short for this VAR order.
- The motion sample rate must be positive.
- The VAR order must be a positive integer.
- The motion sequence must contain at least one value.
AI-assisted analysis of moeru-ai/airi@9c213115f8 (2026-09-02).
Data as JSON: /api/errors/6de025e7afc0c0ef.
Report an issue: GitHub.