{"record":{"id":"d7ef6266f3f300b2","repo":"affaan-m/ECC","slug":"missing-value-for-arg-d7ef62","errorCode":null,"errorMessage":"Missing value for ${arg}","messagePattern":"Missing value for (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/work-items.js","lineNumber":107,"sourceCode":"    json: false,\n    limit: 20,\n    positionals: []\n  };\n\n  if (args[0] && !args[0].startsWith('-')) {\n    parsed.command = args.shift();\n  }\n\n  for (let index = 0; index < args.length; index += 1) {\n    const arg = args[index];\n    if (arg === '--help' || arg === '-h') {\n      parsed.help = true;\n    } else if (arg === '--json') {\n      parsed.json = true;\n    } else if (VALUE_FLAGS.has(arg)) {\n      const value = args[index + 1];\n      if (!value || value.startsWith('--')) {\n        throw new Error(`Missing value for ${arg}`);\n      }\n      assignOption(parsed, arg, value);\n      index += 1;\n    } else if (!arg.startsWith('-')) {\n      parsed.positionals.push(arg);\n    } else {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n  }\n\n  return parsed;\n}\n\nfunction parseMetadataJson(value) {\n  if (value === undefined || value === null) {\n    return null;\n  }\n","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/work-items.js#L89-L125","documentation":"For flags in the VALUE_FLAGS set, parseArgs reads the next argv token as the value and rejects a missing or '--'-prefixed token, mirroring welcome.js behavior. This catches flags given without their required value before assignOption is ever called.","triggerScenarios":"`node scripts/work-items.js add --title` (nothing after), or `--status --json` where the next token is another flag, or an empty interpolated shell variable as the value.","commonSituations":"Empty environment variables in CI pipelines feeding flag values; truncation when copy-pasting multi-flag commands; forgetting that a value starting with a hyphen (like a negative number) is rejected by the startsWith('--') heuristic.","solutions":["Provide the value in the next argv slot: `--title \"My work item\"`","Quote values that may be empty or contain dashes, and verify shell variables are set","Reorder flags so a value never collides with the following flag","For dash-leading literal values, check whether an `=` form or quoting workaround exists in this parser"],"exampleFix":"// before\nnode scripts/work-items.js add --title\n// after\nnode scripts/work-items.js add --title \"Fix login bug\"","handlingStrategy":"validation","validationCode":"for (const flag of ['--title','--status','--source' /* VALUE_FLAGS */]) {\n  const i = process.argv.indexOf(flag);\n  if (i !== -1) {\n    const v = process.argv[i + 1];\n    if (v === undefined || v.startsWith('--')) {\n      throw new Error(`Missing value for ${flag}`);\n    }\n  }\n}","typeGuard":"function flagHasValue(argv, flag) {\n  const i = argv.indexOf(flag);\n  return i !== -1 && typeof argv[i + 1] === 'string' && !argv[i + 1].startsWith('--');\n}","tryCatchPattern":"try {\n  const options = parseArgs(process.argv);\n} catch (err) {\n  if (err.message.startsWith('Missing value for')) {\n    console.error(`${err.message} — supply the value in the next argument.`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Quote values containing spaces or dashes","Use ${VAR:?msg} shell guards to catch empty interpolations","Order flags so values never abut the next flag","Remember values starting with '-' are rejected by the parser's heuristic"],"tags":["cli","arguments","validation"],"backgroundTag":"missing-cli-argument","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}