moeru-ai/airi · error · Error

Unsupported AVIF max width "${argv[avifMaxWidthFlagIndex + 1

Error message

Unsupported AVIF max width "${argv[avifMaxWidthFlagIndex + 1] ?? avifMaxWidth}". Expected a number >= 1.

What it means

The value of --avif-max-width is coerced with Number() (capture.ts:26) and must be a finite number >= 1 (capture.ts:91) because avifTransformer uses it as the target pixel width for downscaling (capture.ts:38-41). This error fires when the string is non-numeric or less than 1, echoing the offending raw value in the message.

Source

Thrown at packages/scenarios-stage-tamagotchi-browser/scripts/capture.ts:91

if (avifMaxWidthFlagIndex >= 0 && !argv[avifMaxWidthFlagIndex + 1]) {
  throw new Error('Missing value for --avif-max-width.')
}

if (avifQualityFlagIndex >= 0 && !argv[avifQualityFlagIndex + 1]) {
  throw new Error('Missing value for --avif-quality.')
}

if (avifSpeedFlagIndex >= 0 && !argv[avifSpeedFlagIndex + 1]) {
  throw new Error('Missing value for --avif-speed.')
}

if (!Number.isFinite(settleMs) || settleMs < 0) {
  throw new Error(`Unsupported settle delay "${argv[settleMsFlagIndex + 1] ?? settleMs}". Expected a number >= 0.`)
}

if (!Number.isFinite(avifMaxWidth) || avifMaxWidth < 1) {
  throw new Error(`Unsupported AVIF max width "${argv[avifMaxWidthFlagIndex + 1] ?? avifMaxWidth}". Expected a number >= 1.`)
}

if (!Number.isFinite(avifQuality) || avifQuality < 0 || avifQuality > 100) {
  throw new Error(`Unsupported AVIF quality "${argv[avifQualityFlagIndex + 1] ?? avifQuality}". Expected a number between 0 and 100.`)
}

if (!Number.isFinite(avifSpeed) || avifSpeed < 1 || avifSpeed > 10) {
  throw new Error(`Unsupported AVIF speed "${argv[avifSpeedFlagIndex + 1] ?? avifSpeed}". Expected a number between 1 and 10.`)
}

await captureBrowserRoots({
  imageTransformers: requestedFormat === 'avif'
    ? [avifTransformer]
    : undefined,
  sceneAppRoot,
  routePath,
  outputDir,
  settleMs,

View on GitHub (pinned to 677329427f)

Solutions

  1. Pass a positive pixel width: `--avif-max-width 1200`
  2. To keep full resolution, pass the actual capture width (e.g. 1920) instead of 0
  3. Verify no stray flag or empty string follows --avif-max-width

Example fix

// before
pnpm capture --format avif --avif-max-width auto
// after
pnpm capture --format avif --avif-max-width 1200
Defensive patterns

Strategy: validation

Validate before calling

function parseAvifMaxWidth(raw: string | undefined): number {
  const value = raw === undefined ? 1200 : Number(raw)
  if (!Number.isFinite(value) || value < 1)
    throw new Error(`Unsupported AVIF max width "${raw}". Expected a number >= 1.`)
  return value
}

Type guard

const isPositiveInt = (v: unknown): v is number =>
  typeof v === 'number' && Number.isFinite(v) && Number.isInteger(v) && v >= 1

Prevention

When it happens

Trigger: Passing `--avif-max-width auto`, `--avif-max-width 0`, a negative number, or another flag token where the value should be (which coerces to NaN).

Common situations: Copy-pasting CSS-like or human values (`100%`, `auto`, `1x`) from design specs into a CLI that expects pixels; zero entered to mean 'no limit' when the script treats 0 as invalid.

Related errors


AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18). Data as JSON: /api/errors/58ba918ac719b71f. Report an issue: GitHub.