affaan-m/ECC · error

requires a value

Error message

${flagName} requires a value

What it means

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.

Solutions

  1. Supply the value immediately after the flag: `--release v1.2.3`
  2. Audit shell scripts for empty variables generating bare flags
  3. Check --help for which flags require values
  4. Reorder arguments so value-taking flags are followed by their values

Example fix

// before
node scripts/release-approval-gate.js --release
// after
node scripts/release-approval-gate.js --release v1.2.3
Defensive patterns

Strategy: validation

Validate before calling

function validateFlagValue(argv, flag) {
  const i = argv.indexOf(flag);
  if (i === -1) return true;
  const v = argv[i + 1];
  return v !== undefined && !v.startsWith('--');
}
if (!validateFlagValue(process.argv, '--release')) {
  throw new Error('--release requires a value');
}

Try / catch

try {
  await main(process.argv);
} catch (e) {
  if (e.message.endsWith('requires a value')) {
    console.error(`${e.message}. Example: --release v1.2.3`);
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: 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`).

Common situations: 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.

Understand the failure class

Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/1a845de4e69cf81d. Report an issue: GitHub.

Appendix: source

Thrown at scripts/release-approval-gate.js:110

function usage() {
  console.log([
    'Usage: node scripts/release-approval-gate.js [--format <text|json>] [--root <dir>]',
    '',
    'Final approval gate for the release version declared by package.json.',
    '',
    'Options:',
    '  --format <text|json>  Output format (default: text)',
    '  --json                Alias for --format json',
    '  --root <dir>          Repository root to inspect (default: cwd)',
    '  --help, -h            Show this help',
  ].join('\n'));
}

function readArgValue(args, index, flagName) {
  const value = args[index + 1];
  if (!value || value.startsWith('--')) {
    throw new Error(`${flagName} requires a value`);
  }
  return value;
}

function parseArgs(argv) {
  const args = argv.slice(2);
  const parsed = {
    format: 'text',
    help: false,
    root: path.resolve(process.cwd()),
  };

  for (let index = 0; index < args.length; index += 1) {
    const arg = args[index];

    if (arg === '--help' || arg === '-h') {
      parsed.help = true;
      continue;

View on GitHub (pinned to 8321021c54)