affaan-m/ECC · error · Error

Missing value for --action

Error message

Missing value for --action

What it means

welcome.js parseArgs requires a concrete value immediately after --action. If the next argv entry is absent or itself looks like a flag (starts with '--'), the script cannot determine the requested action and throws. This is strict positional value validation for the welcome CLI.

Solutions

  1. Pass a value directly after --action, e.g. `--action install`
  2. Check that the shell variable holding the action is non-empty before invoking
  3. Use space-separated form, not `--action=value`, unless the parser supports it
  4. Run with no args or check the script's help to see valid actions

Example fix

// before
node scripts/welcome.js --action
// after
node scripts/welcome.js --action install
Defensive patterns

Strategy: validation

Validate before calling

const actionIdx = process.argv.indexOf('--action');
const action = actionIdx !== -1 ? process.argv[actionIdx + 1] : undefined;
if (action === undefined || action.startsWith('--')) {
  throw new Error('Missing value for --action');
}

Type guard

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

Try / catch

try {
  const { action } = parseArgs(process.argv.slice(2));
} catch (err) {
  if (err.message.startsWith('Missing value for')) {
    console.error(`Usage: welcome.js --action <${[...VALID_ACTIONS].join('|')}> [--version x.y.z]`);
    process.exit(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling the script with `--action` as the last argument, or `--action --version 1.2.3`, i.e. any invocation where argv[index+1] is undefined or starts with '--'.

Common situations: Typos where the value was accidentally dropped during shell editing; scripts interpolating empty variables (`--action "$ACTION"` with ACTION empty); users writing `--action=...` style not supported by this parser.

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

Appendix: source

Thrown at scripts/welcome.js:27

const VALID_ACTIONS = new Set([
  'installed',
  'updated',
  'configured',
  'migrated',
  'resumed',
  'already-migrated',
]);

function parseArgs(argv) {
  let action = 'installed';
  let version;

  for (let index = 0; index < argv.length; index += 1) {
    const argument = argv[index];
    if (argument === '--action') {
      const value = argv[index + 1];
      if (!value || value.startsWith('--')) {
        throw new Error('Missing value for --action');
      }
      action = value;
      index += 1;
    } else if (argument === '--version') {
      const value = argv[index + 1];
      if (!value || value.startsWith('--')) {
        throw new Error('Missing value for --version');
      }
      version = value;
      index += 1;
    } else {
      throw new Error('Unknown argument');
    }
  }

  if (!VALID_ACTIONS.has(action)) {
    throw new Error('Invalid --action value');
  }

View on GitHub (pinned to 8321021c54)