{"record":{"id":"65f8d1b1389817bf","repo":"affaan-m/ECC","slug":"flagname-requires-a-value-65f8d1","errorCode":null,"errorMessage":"${flagName} requires a value","messagePattern":"(.+?) requires a value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/preview-pack-smoke.js","lineNumber":97,"sourceCode":"];\n\nfunction usage() {\n  console.log([\n    'Usage: node scripts/preview-pack-smoke.js [--format <text|json>] [--root <dir>]',\n    '',\n    'Deterministic smoke gate for the ECC 2.0 rc.1 preview pack.',\n    '',\n    'Options:',\n    '  --format <text|json>  Output format (default: text)',\n    '  --root <dir>          Repository root to inspect (default: cwd)',\n    '  --help, -h            Show this help',\n  ].join('\\n'));\n}\n\nfunction readArgValue(args, index, flagName) {\n  const value = args[index + 1];\n  if (!value || value.startsWith('--')) {\n    throw new Error(`${flagName} requires a value`);\n  }\n  return value;\n}\n\nfunction parseArgs(argv) {\n  const args = argv.slice(2);\n  const parsed = {\n    format: 'text',\n    help: false,\n    root: path.resolve(process.cwd()),\n  };\n\n  for (let index = 0; index < args.length; index += 1) {\n    const arg = args[index];\n\n    if (arg === '--help' || arg === '-h') {\n      parsed.help = true;\n      continue;","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/preview-pack-smoke.js#L79-L115","documentation":"readArgValue in scripts/preview-pack-smoke.js extracts the value that follows a CLI flag and throws when the next token is missing or itself starts with '--'. This enforces that flags like --root or --format receive an actual value rather than silently consuming another flag or undefined.","triggerScenarios":"Running the script with a flag at the end of argv (no following token), e.g. `--root`, or with a value that looks like a flag, e.g. `--root --format json`.","commonSituations":"Typos where the flag value is forgotten; shell scripts building argv dynamically and dropping an empty variable; users writing `--root=--other-flag`-style confusion.","solutions":["Provide the value directly after the flag: `--root /path/to/dir`","Check shell scripts for unset variables producing empty flag values","Use the equals form if supported (e.g. --root=/path) to bind value to flag"],"exampleFix":"// before\nnode scripts/preview-pack-smoke.js --root\n// after\nnode scripts/preview-pack-smoke.js --root /tmp/my-pack","handlingStrategy":"validation","validationCode":"function validateFlagValue(argv, flag) {\n  const i = argv.indexOf(flag);\n  if (i === -1) return true;\n  const v = argv[i + 1];\n  return v !== undefined && !v.startsWith('--');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await main(process.argv);\n} catch (e) {\n  if (e.message.endsWith('requires a value')) {\n    console.error(`${e.message}. Usage: <flag> <value>`);\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Always place flag values immediately after the flag","In shell scripts, guard against empty variables: \"${ROOT:?root required}\"","Prefer --flag=value syntax when supported to bind value to flag","Smoke-test wrapper scripts with all flags before scheduling them"],"tags":["cli","argument-parsing","missing-value"],"backgroundTag":"missing-required-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"}