{"record":{"id":"2e2f335344d64169","repo":"moeru-ai/airi","slug":"missing-value-for-output-dir","errorCode":null,"errorMessage":"Missing value for --output-dir.","messagePattern":"Missing value for --output-dir\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/scenarios-stage-tamagotchi-browser/scripts/capture.ts","lineNumber":67,"sourceCode":"  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\nif (avifQualityFlagIndex >= 0 && !argv[avifQualityFlagIndex + 1]) {\n  throw new Error('Missing value for --avif-quality.')\n}\n\nif (avifSpeedFlagIndex >= 0 && !argv[avifSpeedFlagIndex + 1]) {\n  throw new Error('Missing value for --avif-speed.')\n}\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/scenarios-stage-tamagotchi-browser/scripts/capture.ts#L49-L85","documentation":"The stage-tamagotchi-browser capture script parses process.argv by hand: it locates --output-dir with argv.findIndex (capture.ts:18) and resolves the directory from argv[index + 1] (capture.ts:29-31). This error means the flag token was present but the slot right after it was undefined or an empty string, so no output directory can be resolved. The script intentionally refuses to silently fall back to the default 'artifacts/final' when the user explicitly names the flag.","triggerScenarios":"Running the script with --output-dir as the last token (e.g. `tsx scripts/capture.ts --route / --output-dir`), passing an explicit empty string (`--output-dir \"\"`), or a CI step / shell wrapper that appends the flag without its value.","commonSituations":"Shell scripts that conditionally append flags from possibly-empty variables (`--output-dir \"$OUT_DIR\"` with OUT_DIR unset), shared CI command templates where the path argument gets dropped, or a typo that places the path before the flag.","solutions":["Append a value after the flag: `--output-dir artifacts/final` (relative paths are resolved against the scene app root via path.resolve)","Omit the flag entirely to get the default `<cwd>/artifacts/final`","If the value comes from a variable, default it in the command: `--output-dir \"${OUT_DIR:-artifacts/final}\"`"],"exampleFix":"// before\npnpm capture --route /docs/setup-and-use --output-dir\n// after\npnpm capture --route /docs/setup-and-use --output-dir artifacts/final","handlingStrategy":"validation","validationCode":"// Run before invoking the capture script\nfunction requireFlagValue(argv: string[], flag: string): string | undefined {\n  const i = argv.indexOf(flag)\n  if (i === -1) return undefined // flag absent, default applies\n  const value = argv[i + 1]\n  if (!value) throw new Error(`Missing value for ${flag}.`)\n  return value\n}\nrequireFlagValue(process.argv, '--output-dir')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never append a value-taking flag without its value; build argv from a validated options object","Default empty variables inline in CI: `--output-dir \"${OUT_DIR:-artifacts/final}\"`","Smoke-test capture commands in CI with the exact flag set production uses"],"tags":["cli","argv","vishot","capture","stage-tamagotchi"],"backgroundTag":"missing-cli-argument-value","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"}