moeru-ai/airi · error · Error

Unsupported capture format "${requestedFormat}". Expected "p

Error message

Unsupported capture format "${requestedFormat}". Expected "png" or "avif".

What it means

Thrown by the capture script's argument validation when the requested screenshot format is neither `png` nor `avif`. The script transcodes PNG captures to AVIF via sharp when `avif` is selected, and only those two formats are wired through the pipeline. The check runs early, before any capture work, to fail fast on invalid CLI input.

Source

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

  }

  const avifBuffer = await transformer.avif({
    quality: avifQuality,
    speed: avifSpeed,
  })

  await writeFile(derivedFilePath, avifBuffer)
  await rm(artifact.filePath, { force: true })

  return {
    ...artifact,
    filePath: derivedFilePath,
    format: 'avif',
  }
}

if (!['png', 'avif'].includes(requestedFormat)) {
  throw new Error(`Unsupported capture format "${requestedFormat}". Expected "png" or "avif".`)
}

if (!routePath?.startsWith('/')) {
  throw new Error(`Unsupported route path "${routePath}". Route paths must start with "/".`)
}

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

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

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

View on GitHub (pinned to 27111382b4)

Solutions

  1. Pass `--format png` (default lossless) or `--format avif` (transcoded, smaller) to the capture script.
  2. If you need another format, capture as PNG and post-process with an image tool outside the script.
  3. Remove any unsupported format value from the wrapper script, CI yaml, or env var feeding the flag.
  4. Re-run with `--help` (or read the script header) to confirm the accepted flag values.

Example fix

// before
node scripts/capture.ts --format jpg

// after
node scripts/capture.ts --format avif
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_FORMATS = new Set(['png', 'avif'])
if (!SUPPORTED_FORMATS.has(requestedFormat)) {
  throw new Error(`Unsupported capture format. Use one of: ${[...SUPPORTED_FORMATS].join(', ')}`)
}

Type guard

const CAPTURE_FORMATS = ['png', 'avif'] as const
type CaptureFormat = (typeof CAPTURE_FORMATS)[number]

function isCaptureFormat(value: string): value is CaptureFormat {
  return (CAPTURE_FORMATS as readonly string[]).includes(value)
}

Prevention

When it happens

Trigger: Running the capture script with `--format <something>` (or equivalent) where the value is not `png` or `avif` — e.g. `--format jpg`, `--format webp`, or a typo. Also triggered when the format is sourced from a config/env var without validation.

Common situations: Contributors passing a familiar image format (jpeg/webp) that the script does not support; CI configs or wrapper scripts that set a format flag incorrectly; typos in the format token.

Related errors


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