affaan-m/ECC · error · Error

Missing value for

Error message

Missing value for ${arg}

What it means

For flags in the VALUE_FLAGS set, parseArgs reads the next argv token as the value and rejects a missing or '--'-prefixed token, mirroring welcome.js behavior. This catches flags given without their required value before assignOption is ever called.

Solutions

  1. Provide the value in the next argv slot: `--title "My work item"`
  2. Quote values that may be empty or contain dashes, and verify shell variables are set
  3. Reorder flags so a value never collides with the following flag
  4. For dash-leading literal values, check whether an `=` form or quoting workaround exists in this parser

Example fix

// before
node scripts/work-items.js add --title
// after
node scripts/work-items.js add --title "Fix login bug"
Defensive patterns

Strategy: validation

Validate before calling

for (const flag of ['--title','--status','--source' /* VALUE_FLAGS */]) {
  const i = process.argv.indexOf(flag);
  if (i !== -1) {
    const v = process.argv[i + 1];
    if (v === undefined || v.startsWith('--')) {
      throw new Error(`Missing value for ${flag}`);
    }
  }
}

Type guard

function flagHasValue(argv, flag) {
  const i = argv.indexOf(flag);
  return i !== -1 && typeof argv[i + 1] === 'string' && !argv[i + 1].startsWith('--');
}

Try / catch

try {
  const options = parseArgs(process.argv);
} catch (err) {
  if (err.message.startsWith('Missing value for')) {
    console.error(`${err.message} — supply the value in the next argument.`);
    process.exit(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: `node scripts/work-items.js add --title` (nothing after), or `--status --json` where the next token is another flag, or an empty interpolated shell variable as the value.

Common situations: Empty environment variables in CI pipelines feeding flag values; truncation when copy-pasting multi-flag commands; forgetting that a value starting with a hyphen (like a negative number) is rejected by the startsWith('--') heuristic.

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/d7ef6266f3f300b2. Report an issue: GitHub.

Appendix: source

Thrown at scripts/work-items.js:107

    json: false,
    limit: 20,
    positionals: []
  };

  if (args[0] && !args[0].startsWith('-')) {
    parsed.command = args.shift();
  }

  for (let index = 0; index < args.length; index += 1) {
    const arg = args[index];
    if (arg === '--help' || arg === '-h') {
      parsed.help = true;
    } else if (arg === '--json') {
      parsed.json = true;
    } else if (VALUE_FLAGS.has(arg)) {
      const value = args[index + 1];
      if (!value || value.startsWith('--')) {
        throw new Error(`Missing value for ${arg}`);
      }
      assignOption(parsed, arg, value);
      index += 1;
    } else if (!arg.startsWith('-')) {
      parsed.positionals.push(arg);
    } else {
      throw new Error(`Unknown argument: ${arg}`);
    }
  }

  return parsed;
}

function parseMetadataJson(value) {
  if (value === undefined || value === null) {
    return null;
  }

View on GitHub (pinned to 8321021c54)