affaan-m/ECC · error · Error

Invalid --version value

Error message

Invalid --version value

What it means

Thrown by scripts/welcome.js when --version is supplied but its value does not match the ECC_VERSION_PATTERN regex `^[0-9]+(?:\.[0-9]+){2}(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$`. This requires a full major.minor.patch triplet (e.g. 2.2.0), optionally followed by a hyphen prerelease or plus build metadata. Short forms like '2.2' or 'v2.2.0' (with a leading v) are rejected.

Source

Thrown at scripts/welcome.js:47

      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;
  }
}

if (require.main === module) {

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Supply a full three-part version without a leading 'v': `--version 2.2.0`.
  2. Strip a leading 'v' from git-tag-derived versions before passing them to welcome.js.
  3. If using a prerelease or build tag, follow semver: `--version 2.2.0-beta.1` or `--version 2.2.0+sha.abc123`.

Example fix

// before
node scripts/welcome.js --version v2.2.0

// after
node scripts/welcome.js --version 2.2.0
Defensive patterns

Strategy: type-guard

Validate before calling

const ECC_VERSION_PATTERN = /^[0-9]+(?:\.[0-9]+){2}(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
function normalizeEccVersion(raw) {
  if (!raw) return null;
  const v = String(raw).replace(/^v/, '');
  if (!ECC_VERSION_PATTERN.test(v)) {
    throw new Error(`Invalid ECC version: ${raw}. Expected X.Y.Z (optionally with - prerelease or + build).`);
  }
  return v;
}

Type guard

function isValidEccVersion(value) {
  const cleaned = String(value).replace(/^v/, '');
  return /^[0-9]+(?:\.[0-9]+){2}(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(cleaned);
}

Prevention

When it happens

Trigger: `node scripts/welcome.js --version 2.2` (only two segments); `--version v2.2.0` (leading 'v'); `--version latest` (non-numeric); `--version 2.2.0.0` (four segments — still passes the numeric pattern actually, since the regex allows 2.2.0.0 as major.minor.patch then a trailing group; re-examining: the pattern is `[0-9]+(?:\.[0-9]+){2}` which matches exactly three numeric groups, so 2.2.0.0 would fail).

Common situations: A build pipeline that derives the version from a git tag like 'v2.2.0' without stripping the leading 'v'; package.json scripts passing a two-part version; human-typed shorthand versions.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/c6d5a05eefff354f. Report an issue: GitHub.