{"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":"exception","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/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/work-items.js#L89-L125","documentation":"Thrown by scripts/work-items.js parseArgs when a VALUE_FLAGS member (e.g. --id, --title, --limit, --owner, --db, etc.) is passed but the next token is missing or itself starts with '--'. The guard `if (!value || value.startsWith('--'))` prevents one flag from silently consuming the next flag's name as its value. Each value flag requires a concrete argument.","triggerScenarios":"`node scripts/work-items.js upsert --title` (no title text); `node scripts/work-items.js claim --owner` (no owner name); `node scripts/work-items.js list --limit --json` (--limit immediately followed by --json).","commonSituations":"A wrapper script interpolating an empty variable into a flag value; reordering flags so a value flag lands last; passing a flag whose value legitimately could start with '--' is intentionally rejected to avoid ambiguity.","solutions":["Provide a non-flag value immediately after the flag: `--title \"Ship feature X\"`.","If the value would legitimately be empty, omit the flag rather than passing it empty.","Reorder so the value flag is not immediately followed by another flag."],"exampleFix":"// before\nnode scripts/work-items.js upsert --title\n\n// after\nnode scripts/work-items.js upsert --title \"Ship feature X\"","handlingStrategy":"validation","validationCode":"const VALUE_FLAGS = new Set(['--as','--db','--github-repo','--id','--limit','--metadata-json','--owner','--priority','--repo','--repo-root','--session','--session-id','--source','--source-id','--status','--title','--url']);\nfunction validateWorkItemsArgs(argv) {\n  for (let i = 0; i < argv.length; i++) {\n    const tok = argv[i];\n    if (VALUE_FLAGS.has(tok)) {\n      const val = argv[i + 1];\n      if (!val || val.startsWith('--')) {\n        throw new Error(`Flag ${tok} requires a value`);\n      }\n      i += 1;\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide a concrete value immediately after a value flag.","Do not let two value flags sit adjacent without values between them.","Construct work-items argv with a helper that pairs each value flag with its value."],"tags":["cli","argument-parsing","missing-value","work-items","validation"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}