affaan-m/ECC · error · Error

requires a value

Error message

${flagName} requires a value

What it means

readValue in operator-readiness-dashboard.js retrieves the value following a value-taking flag (e.g. --format, integer flags). If the next token is missing or starts with '--', it throws this error so a flag is never silently consumed as another flag's value.

Solutions

  1. Provide the value immediately after the flag.
  2. Reorder flags so value-taking flags are followed by their values.
  3. Guard shell variables: `--port "${PORT:?PORT not set}"`.
  4. Check the script's usage output for which flags require values.

Example fix

// before
node scripts/operator-readiness-dashboard.js --format
// after
node scripts/operator-readiness-dashboard.js --format json
Defensive patterns

Strategy: validation

Validate before calling

const VALUE_FLAGS = ['--format','--port','--limit'];
for (const f of VALUE_FLAGS) {
  const i = args.indexOf(f);
  if (i !== -1 && (!args[i+1] || args[i+1].startsWith('--'))) throw new Error(`${f} needs a value`);
}

Try / catch

try {
  runDashboard(argv);
} catch (err) {
  if (err.message.endsWith('requires a value')) {
    console.error('Provide the value immediately after the flag.');
  } else throw err;
}

Prevention

When it happens

Trigger: Running the dashboard script with a flag like `--port` or `--format` as the last argument, or followed directly by another flag, e.g. `--format --json`; any value flag adjacent to another flag without its value.

Common situations: Empty shell variable interpolation before a value; truncated command lines from docs; reordering flags so a value flag ends the command; scripts building argv arrays that drop the value element.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


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

Appendix: source

Thrown at scripts/operator-readiness-dashboard.js:45

    '  --write <path>             Write json or markdown output to a file',
    '  --root <dir>               Repository root to inspect (default: cwd)',
    '  --repo <owner/repo>        GitHub repo to inspect; repeatable',
    '  --skip-github              Skip live GitHub queue/discussion checks',
    '  --max-open-prs <n>         PR budget passed through to platform:audit',
    '  --max-open-issues <n>      Issue budget passed through to platform:audit',
    '  --max-dirty-files <n>      Dirty-file budget passed through to platform:audit',
    '  --allow-untracked <path>   Ignore untracked files under path; repeatable',
    '  --use-env-github-token     Keep GITHUB_TOKEN when invoking gh',
    '  --generated-at <iso>       Override generatedAt for deterministic tests',
    '  --exit-code                Return 2 when the objective is not ready',
    '  --help, -h                 Show this help',
  ].join('\n'));
}

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

function parseIntegerFlag(value, flagName) {
  const parsed = Number.parseInt(value, 10);
  if (!Number.isFinite(parsed) || parsed < 0) {
    throw new Error(`Invalid ${flagName}: ${value}`);
  }
  return parsed;
}

function normalizeRelativePrefix(value) {
  const normalized = String(value || '')
    .replace(/\\/g, '/')
    .replace(/^\.\/+/, '')
    .replace(/\/+$/, '');
  return normalized ? `${normalized}/` : '';

View on GitHub (pinned to 8321021c54)