{"record":{"id":"1a845de4e69cf81d","repo":"affaan-m/ECC","slug":"flagname-requires-a-value-1a845d","errorCode":null,"errorMessage":"${flagName} requires a value","messagePattern":"(.+?) requires a value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/release-approval-gate.js","lineNumber":110,"sourceCode":"\nfunction usage() {\n  console.log([\n    'Usage: node scripts/release-approval-gate.js [--format <text|json>] [--root <dir>]',\n    '',\n    'Final approval gate for the release version declared by package.json.',\n    '',\n    'Options:',\n    '  --format <text|json>  Output format (default: text)',\n    '  --json                Alias for --format json',\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":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/release-approval-gate.js#L92-L128","documentation":"readArgValue in scripts/release-approval-gate.js fetches the token following a flag and throws this error when the next argv entry is missing or begins with '--'. It guarantees flags that require values (e.g. --release, --format) actually receive one, preventing flags from being silently consumed as values.","triggerScenarios":"Invoking the script with a value-taking flag as the last argument (e.g. `--release`), or with another flag in the value slot (e.g. `--release --env prod`).","commonSituations":"Shell scripts dropping an empty RELEASE variable into argv; typos omitting the value; users structuring arguments as `--release --tag v1.2` where --release needs its own value.","solutions":["Supply the value immediately after the flag: `--release v1.2.3`","Audit shell scripts for empty variables generating bare flags","Check --help for which flags require values","Reorder arguments so value-taking flags are followed by their values"],"exampleFix":"// before\nnode scripts/release-approval-gate.js --release\n// after\nnode scripts/release-approval-gate.js --release v1.2.3","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}\nif (!validateFlagValue(process.argv, '--release')) {\n  throw new Error('--release requires a value');\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}. Example: --release v1.2.3`);\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Place values directly after value-taking flags","Use \"${RELEASE:?required}\" in shell wrappers to catch unset vars","Check --help for which flags need values","Never let a value-taking flag be the last argument bare"],"tags":["cli","argument-parsing","missing-value"],"backgroundTag":"missing-required-flag","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"}