{"record":{"id":"ae9fc0c096607977","repo":"itwanger/toBeBetterJavaer","slug":"missing-value-for-argv-index-ae9fc0","errorCode":null,"errorMessage":"Missing value for ${argv[index]}","messagePattern":"Missing value for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/sync-sidebar.js","lineNumber":95,"sourceCode":"      index += 1;\n    } else if (arg.startsWith(\"--fallback=\")) {\n      options.fallbackGroup = arg.slice(\"--fallback=\".length);\n    } else {\n      throw new Error(`Unknown option: ${arg}`);\n    }\n  }\n\n  if ((options.route && !options.dir) || (!options.route && options.dir)) {\n    throw new Error(\"--route and --dir must be used together\");\n  }\n\n  return options;\n}\n\nfunction requireValue(argv, index) {\n  const value = argv[index + 1];\n  if (!value || value.startsWith(\"-\")) {\n    throw new Error(`Missing value for ${argv[index]}`);\n  }\n  return value;\n}\n\nfunction normalizeRoute(route) {\n  if (!route.startsWith(\"/\")) {\n    route = `/${route}`;\n  }\n  if (!route.endsWith(\"/\")) {\n    route = `${route}/`;\n  }\n  return route;\n}\n\nfunction createTargets(options) {\n  if (options.route) {\n    return [\n      {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/itwanger/toBeBetterJavaer/blob/6617f5fd0b0597735bdc028f2fcd036817877327/scripts/sync-sidebar.js#L77-L113","documentation":"Thrown by requireValue() in scripts/sync-sidebar.js when a value-taking option (--sidebar, --route, --dir, --fallback) is last on the command line or its next token starts with '-'. It applies to the space-separated form only; the --option=value form bypasses this check.","triggerScenarios":"`node scripts/sync-sidebar.js --route` as the final token; `--dir --check`; `--fallback -group` where the intended value itself begins with '-'.","commonSituations":"Truncated shell history entries; flag reordering; values that legitimately start with a dash (rare — routes and dir paths do not).","solutions":["Add the missing value or switch to the equals form: `--route=/sidebar/itwanger/ai/`","Reorder so the value does not sit next to another flag","Values beginning with '-' are unsupported in space form — restructure the value"],"exampleFix":"# before\nnode scripts/sync-sidebar.js --sidebar\n\n# after\nnode scripts/sync-sidebar.js --sidebar=docs/src/.vuepress/sidebar.ts","handlingStrategy":"validation","validationCode":"const VALUE_OPTS = [\"--sidebar\", \"--route\", \"--dir\", \"--fallback\"];\nfor (let i = 0; i < args.length; i++) {\n  if (VALUE_OPTS.includes(args[i]) && (!args[i + 1] || args[i + 1].startsWith(\"-\"))) {\n    throw new Error(`${args[i]} needs a value — use ${args[i]}=value`);\n  }\n}","typeGuard":null,"tryCatchPattern":"catch (err) { if (err.message.startsWith(\"Missing value for\")) { console.error(\"Use the --option=value form\"); process.exit(2); } throw err; }","preventionTips":["Prefer --option=value for --sidebar/--route/--dir/--fallback","Never let a value-taking flag be the last token","Review truncated shell-history commands before running them"],"tags":["cli","argument-parsing","usage-error"],"backgroundTag":null,"analyzedSha":"6617f5fd0b0597735bdc028f2fcd036817877327","analyzedAt":"2026-08-14T14:50:55.107Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}