affaan-m/ECC · error · Error

${flagName} requires a value

Error message

${flagName} requires a value

What it means

Thrown by readArgValue in release-approval-gate's arg parser when a value-taking flag (--format, --root) is followed by nothing or by another `--` flag. Same strict-value guard used across ECC scripts so a flag name is never silently consumed as a value. The gate validates release readiness, so its inputs must be unambiguous.

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 01e15490f0)

Solutions

  1. Provide the value after the flag: `--format json` or `--root /repo`.
  2. Use the `=` form: `--format=json`, `--root=/repo`.
  3. Ensure any shell/env variable used as the value is non-empty and quoted.

Example fix

# before
node scripts/release-approval-gate.js --root --json
# after
node scripts/release-approval-gate.js --root /path/to/repo --json
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

function isFlagValueTok(token) {
  return typeof token === 'string' && token.length > 0 && !token.startsWith('--');
}

Try / catch

try {
  parseArgs(process.argv);
} catch (err) {
  if (err.message.endsWith('requires a value')) {
    console.error(`${err.message}. Use --flag=value form.`);
    process.exit(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: `--format` last; `--root --json` (root value missing); templated value that resolved empty; copy-paste that dropped the value.

Common situations: CI template assembles the command and a variable was empty; user edited an example and removed a value.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/1a845de4e69cf81d. Report an issue: GitHub.