Egonex-AI/Understand-Anything · error · CliUsageError

${flag} requires a value

Error message

${flag} requires a value

What it means

CliUsageError thrown by the takeValue helper when a flag that expects a following argument (--repo, --output/-o, --label, --concurrency) is followed by a missing value or a value that itself starts with '--'. It prevents silently consuming the next flag as a value.

Source

Thrown at scripts/lib/large-repo-benchmark.mjs:131

  constructor() {
    super('Unable to remove temporary benchmark artifacts');
    this.name = 'BenchmarkArtifactCleanupError';
  }
}

export function cleanupBenchmarkArtifacts(artifactRoot, operations = {}) {
  const remove = operations.rmSync ?? rmSync;
  try {
    remove(artifactRoot, { recursive: true, force: true });
  } catch {
    throw new BenchmarkArtifactCleanupError();
  }
}

function takeValue(argv, index, flag) {
  const value = argv[index + 1];
  if (!value || value.startsWith('--')) {
    throw new CliUsageError(`${flag} requires a value`);
  }
  return value;
}

function parseConcurrency(value) {
  return /^[0-9]+$/.test(value) ? Number(value) : Number.NaN;
}

function canonicalizePhysicalPath(pathValue) {
  const lexicalPath = resolve(withoutExtendedWindowsPrefix(pathValue));
  const missingComponents = [];
  let existingAncestor = lexicalPath;
  let ancestorExists = existsSync(existingAncestor);

  while (!ancestorExists) {
    const parent = dirname(existingAncestor);
    if (parent === existingAncestor) break;
    missingComponents.unshift(basename(existingAncestor));

View on GitHub (pinned to 32944829e7)

Solutions

  1. Provide the value immediately after the flag: --output path/to/report.json.
  2. Use the '=' form which does not consume the next token: --output=path/to/report.json.
  3. Ensure the value does not itself start with '--'; if it legitimately does, use the '=' form or quote it differently.
  4. Run the command with --help to confirm the expected flag/value shape.

Example fix

# before
node benchmark-large-repo.mjs myrepo --output
# after
node benchmark-large-repo.mjs myrepo --output=reports/out.json
Defensive patterns

Strategy: validation

Validate before calling

function flagHasValue(argv: string[], index: number): boolean {
  const next = argv[index + 1];
  return Boolean(next) && !next.startsWith('--');
}

Try / catch

try { const opts = parseArgs(argv); } catch (e) { if ((e as Error).name === 'CliUsageError') { console.error(e.message); process.exit(2); } throw e; }

Prevention

When it happens

Trigger: Passing '--output' as the last token; '--output --label x' (next token is a flag); '--concurrency' at end of argv; any flag whose value token begins with '--'.

Common situations: Typing the command without a value; copy-pasting a command where a value was dropped; a shell that swallowed an empty argument; misordering flags so one flag runs into the next.

Related errors


AI-assisted analysis of Egonex-AI/Understand-Anything@32944829e7 (2026-08-12). Data as JSON: /api/errors/38e352b72dfe6713. Report an issue: GitHub.