{"record":{"id":"6d5e74f8ff7cb6f7","repo":"moeru-ai/airi","slug":"unsupported-capture-format-requestedformat-e","errorCode":null,"errorMessage":"Unsupported capture format \"${requestedFormat}\". Expected \"png\" or \"avif\".","messagePattern":"Unsupported capture format \"(.+?)\"\\. Expected \"png\" or \"avif\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/scenarios-stage-tamagotchi-browser/scripts/capture.ts","lineNumber":59,"sourceCode":"  }\n\n  const avifBuffer = await transformer.avif({\n    quality: avifQuality,\n    speed: avifSpeed,\n  })\n\n  await writeFile(derivedFilePath, avifBuffer)\n  await rm(artifact.filePath, { force: true })\n\n  return {\n    ...artifact,\n    filePath: derivedFilePath,\n    format: 'avif',\n  }\n}\n\nif (!['png', 'avif'].includes(requestedFormat)) {\n  throw new Error(`Unsupported capture format \"${requestedFormat}\". Expected \"png\" or \"avif\".`)\n}\n\nif (!routePath?.startsWith('/')) {\n  throw new Error(`Unsupported route path \"${routePath}\". Route paths must start with \"/\".`)\n}\n\nif (outputDirFlagIndex >= 0 && !argv[outputDirFlagIndex + 1]) {\n  throw new Error('Missing value for --output-dir.')\n}\n\nif (settleMsFlagIndex >= 0 && !argv[settleMsFlagIndex + 1]) {\n  throw new Error('Missing value for --settle-ms.')\n}\n\nif (avifMaxWidthFlagIndex >= 0 && !argv[avifMaxWidthFlagIndex + 1]) {\n  throw new Error('Missing value for --avif-max-width.')\n}\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/scenarios-stage-tamagotchi-browser/scripts/capture.ts#L41-L77","documentation":"Thrown by the capture.ts CLI guard when the --format flag value is neither 'png' nor 'avif'. The script validates argv before invoking captureBrowserRoots because the AVIF path installs an @napi-rs/image transformer and the PNG path must not, so the format must be an exact lowercase literal.","triggerScenarios":"Running the script with --format jpg, --format webp, --format PNG (uppercase), or --format with a missing value (undefined fails the includes check); a wrapper/CI script templating the format from a variable with unexpected values.","commonSituations":"CI pipelines parameterizing screenshot format; contributors assuming webp/jpeg support because AVIF is supported; shell scripts passing user input straight through; casing mistakes.","solutions":["Pass a supported literal: pnpm capture -- --format avif (or --format png, the default when the flag is omitted).","Lowercase the value in wrappers: --format \"${FORMAT,,}\".","If you need another format, capture as png and convert afterwards with your own tooling.","Check for missing flag values (a trailing --format with nothing after it also lands here)."],"exampleFix":"# before\npnpm capture -- --format jpg # throws: Unsupported capture format \"jpg\"\n\n# after\npnpm capture -- --format avif","handlingStrategy":"validation","validationCode":"// In wrappers/CI before invoking capture.ts:\nconst FORMAT = (process.env.CAPTURE_FORMAT ?? 'png').toLowerCase()\nif (!['png', 'avif'].includes(FORMAT)) {\n  throw new Error(`CAPTURE_FORMAT must be 'png' or 'avif', got '${FORMAT}'`)\n}","typeGuard":"const CAPTURE_FORMATS = ['png', 'avif'] as const\nconst isCaptureFormat = (value: string): value is typeof CAPTURE_FORMATS[number] =>\n  (CAPTURE_FORMATS as readonly string[]).includes(value)","tryCatchPattern":null,"preventionTips":["Pass the format literally in scripts; lowercase any variable input.","Remember png is the default — omit --format rather than passing an unsupported value."],"tags":["capture-script","cli","arguments","format"],"backgroundTag":"invalid-cli-argument","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}