affaan-m/ECC · error · Error

Invalid --action value

Error message

Invalid --action value

What it means

After parsing, parseArgs validates the action against the VALID_ACTIONS set. A syntactically valid --action value that is not a member of that set is rejected. This distinguishes well-formed but unsupported actions from missing values (error 671).

Solutions

  1. Use one of the exact values in VALID_ACTIONS (read the top of scripts/welcome.js for the set)
  2. Fix casing to match the declared constants
  3. Check the repo README or welcome script docs for current action names
  4. If a needed action is genuinely missing, this may be a version issue — update the repo

Example fix

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

Strategy: validation

Validate before calling

const VALID_ACTIONS = new Set(['install', 'update', 'uninstall']);
const action = process.argv[process.argv.indexOf('--action') + 1];
if (action !== undefined && !VALID_ACTIONS.has(action)) {
  throw new Error(`Invalid --action value: ${action}`);
}

Type guard

function isValidAction(value) {
  return typeof value === 'string' && VALID_ACTIONS.has(value);
}

Try / catch

try {
  parseArgs(process.argv.slice(2));
} catch (err) {
  if (err.message === 'Invalid --action value') {
    console.error(`Action must be one of: ${[...VALID_ACTIONS].join(', ')}`);
    process.exit(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: `node scripts/welcome.js --action frobnicate` where 'frobnicate' is not in VALID_ACTIONS; also passing an empty-ish or differently-cased action like 'Install' if the set only contains lowercase entries.

Common situations: Guessing action names instead of checking docs; case mismatch ('Install' vs 'install'); outdated docs or muscle memory from a renamed action in a newer script version.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at scripts/welcome.js:44

      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');
  }
  if (version !== undefined && !ECC_VERSION_PATTERN.test(version)) {
    throw new Error('Invalid --version value');
  }
  return { action, version };
}

function main(argv = process.argv.slice(2)) {
  try {
    const { action, version } = parseArgs(argv);
    const color = process.env.NO_COLOR === undefined
      && process.env.TERM !== 'dumb'
      && Boolean(process.stdout.isTTY);
    process.stdout.write(renderTerminalWelcome({ action, color, version }));
  } catch (error) {
    process.stderr.write(`Error: ${error.message}\n`);
    process.exitCode = 1;
  }

View on GitHub (pinned to 8321021c54)