{"record":{"id":"3023c951c7d88f46","repo":"moeru-ai/airi","slug":"missing-value-for-optionname","errorCode":null,"errorMessage":"Missing value for `${optionName}`.","messagePattern":"Missing value for `(.+?)`\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cap-vite/src/index.ts","lineNumber":54,"sourceCode":"  return fileURLToPath(new URL(`./vite-wrapper-config${wrapperExtension}`, import.meta.url))\n}\n\nfunction parseViteConfigLoader(value: string | undefined): 'bundle' | 'native' | 'runner' | undefined {\n  if (value === 'bundle' || value === 'native' || value === 'runner') {\n    return value\n  }\n\n  return undefined\n}\n\nfunction resolveConfigPath(cwd: string, value: string): string {\n  return resolve(cwd, value)\n}\n\nfunction readRequiredOptionValue(viteArgs: string[], index: number, optionName: string): string {\n  const value = viteArgs[index + 1]\n  if (!value) {\n    throw new Error(`Missing value for \\`${optionName}\\`.`)\n  }\n\n  return value\n}\n\nfunction parseConfigArg(viteArgs: string[], index: number, cwd: string): ParsedViteArg | null {\n  const arg = viteArgs[index]\n\n  // NOTICE: Vite only accepts one `--config` entrypoint. cap-vite consumes that slot\n  // for its wrapper config, then loads the user config from inside the wrapper.\n  if (arg === '--config' || arg === '-c') {\n    return {\n      baseConfigFile: resolveConfigPath(cwd, readRequiredOptionValue(viteArgs, index, '--config')),\n      consumedArgs: 2,\n      forwardedArgs: [],\n    }\n  }\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/packages/cap-vite/src/index.ts#L36-L72","documentation":"readRequiredOptionValue reads viteArgs[index + 1] for a flag that needs a value (e.g. --config / -c) and throws when that value is missing/falsy. This protects against an option being the last token or followed by another flag, which would otherwise silently pass undefined downstream.","triggerScenarios":"`cap-vite --config -- ios` where the value slot is occupied by the separator; `--config` as the final token; an empty-string value; an option flag followed immediately by another flag like `--config --mode`.","commonSituations":"Users omitting the config path; argv mis-sliced by a wrapping script; chaining multiple options and forgetting one value; CI templates that conditionally inject a flag without its value.","solutions":["Always supply a concrete value immediately after --config / -c.","When building argv conditionally, push both the flag and its value together or skip both.","Validate the assembled argv shape (flag followed by a non-flag, non-separator token) before running cap-vite."],"exampleFix":"# before\ncap-vite --config -- ios\n\n# after\ncap-vite --config ./vite.config.ts -- ios","handlingStrategy":"validation","validationCode":"function ensureOptionValue(argv: string[], i: number, name: string) {\n  const next = argv[i + 1]\n  if (!next || next.startsWith('-') || next === '--') {\n    throw new Error(`Option ${name} requires a value`)\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  return readRequiredOptionValue(viteArgs, index, optionName)\n}\ncatch (err) {\n  if (/Missing value/i.test((err as Error).message)) {\n    console.error(`Provide a value for ${optionName}`)\n    process.exit(1)\n  }\n  throw err\n}","preventionTips":["Always supply a concrete value immediately after options like --config / -c.","When building argv conditionally, push the flag and its value as a pair.","Validate the argv shape (flag followed by a non-flag value) before running cap-vite."],"tags":["cli","argv","validation","vite","config"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}