{"record":{"id":"ec27d523fa48c863","repo":"affaan-m/ECC","slug":"missing-value-for-version","errorCode":null,"errorMessage":"Missing value for --version","messagePattern":"Missing value for --version","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/welcome.js","lineNumber":34,"sourceCode":"]);\n\nfunction parseArgs(argv) {\n  let action = 'installed';\n  let version;\n\n  for (let index = 0; index < argv.length; index += 1) {\n    const argument = argv[index];\n    if (argument === '--action') {\n      const value = argv[index + 1];\n      if (!value || value.startsWith('--')) {\n        throw new Error('Missing value for --action');\n      }\n      action = value;\n      index += 1;\n    } else if (argument === '--version') {\n      const value = argv[index + 1];\n      if (!value || value.startsWith('--')) {\n        throw new Error('Missing value for --version');\n      }\n      version = value;\n      index += 1;\n    } else {\n      throw new Error('Unknown argument');\n    }\n  }\n\n  if (!VALID_ACTIONS.has(action)) {\n    throw new Error('Invalid --action value');\n  }\n  if (version !== undefined && !ECC_VERSION_PATTERN.test(version)) {\n    throw new Error('Invalid --version value');\n  }\n  return { action, version };\n}\n\nfunction main(argv = process.argv.slice(2)) {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/welcome.js#L16-L52","documentation":"Thrown by scripts/welcome.js parseArgs when --version is passed but the next argv token is missing or starts with '--'. The same guard as --action (`!value || value.startsWith('--')`) prevents consuming the next flag as the version string. --version annotates the welcome banner with the installed ECC version and must be a complete value.","triggerScenarios":"`node scripts/welcome.js --version` (last token); `node scripts/welcome.js --action installed --version` (--version last); `--version --action installed` (next token is a flag).","commonSituations":"An install hook passing `--version $VERSION` where $VERSION is unset for a dev/local build; truncating a command while editing; a packaging script that only sets the version variable on tagged builds.","solutions":["Supply a semver-style version after --version: `node scripts/welcome.js --version 2.2.0`.","If you do not need to show a version, omit the flag entirely.","Ensure the wrapper interpolates a real version string (must match X.Y.Z, optionally with - prerelease or + build metadata)."],"exampleFix":"// before\nnode scripts/welcome.js --version\n\n// after\nnode scripts/welcome.js --version 2.2.0","handlingStrategy":"validation","validationCode":"const ECC_VERSION_PATTERN = /^[0-9]+(?:\\.[0-9]+){2}(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/;\nconst rawVersion = process.env.ECC_VERSION;\nconst version = rawVersion ? rawVersion.replace(/^v/, '') : null; // strip leading 'v'\nconst args = [];\nif (version && ECC_VERSION_PATTERN.test(version)) {\n  args.push('--version', version);\n}","typeGuard":"function isValidEccVersion(value) {\n  const cleaned = String(value).replace(/^v/, '');\n  return /^[0-9]+(?:\\.[0-9]+){2}(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/.test(cleaned);\n}","tryCatchPattern":null,"preventionTips":["Strip a leading 'v' from git-tag-derived versions before passing them.","Require a full major.minor.patch; reject two-part versions upstream.","Centralize version formatting in one helper used by all install hooks."],"tags":["cli","argument-parsing","missing-value","welcome","version"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}