{"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":"validation","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/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/welcome.js#L16-L52","documentation":"Symmetric to the --action check: parseArgs demands a non-flag value right after --version. An absent or '--'-prefixed next argument means the version could not be read, so the parser throws before any ECC_VERSION_PATTERN validation happens.","triggerScenarios":"Invoking `node scripts/welcome.js --action install --version` (version omitted at end of argv) or `--version --action install` where the following token is another flag.","commonSituations":"Copy-pasting commands where the version placeholder was never filled in; CI matrices where a version variable is empty; combining flags in the wrong order assuming `=` syntax.","solutions":["Supply the version value immediately after --version, e.g. `--version 2.2.1`","Ensure the version variable in your script/CI is set and non-empty","Verify the version matches the expected pattern (see 'Invalid --version value')","Use the action-only form if you don't need to pin a version"],"exampleFix":"// before\nnode scripts/welcome.js --action update --version\n// after\nnode scripts/welcome.js --action update --version 2.2.1","handlingStrategy":"validation","validationCode":"const versionIdx = process.argv.indexOf('--version');\nconst version = versionIdx !== -1 ? process.argv[versionIdx + 1] : undefined;\nif (version === undefined || version.startsWith('--')) {\n  throw new Error('Missing value for --version');\n}","typeGuard":"function hasFlagValue(argv, flag) {\n  const i = argv.indexOf(flag);\n  return i !== -1 && typeof argv[i + 1] === 'string' && !argv[i + 1].startsWith('--');\n}","tryCatchPattern":"try {\n  parseArgs(process.argv.slice(2));\n} catch (err) {\n  if (err.message === 'Missing value for --version') {\n    console.error('Provide a version after --version, e.g. --version 2.2.1');\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Pin versions in CI variables and fail fast if the variable is empty","Never leave a --version placeholder unfilled when copy-pasting commands","Verify interpolated values before building the argv array programmatically"],"tags":["cli","arguments","validation"],"backgroundTag":"missing-cli-argument","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}