{"record":{"id":"e5fd308be9877f93","repo":"affaan-m/ECC","slug":"missing-value-for-action","errorCode":null,"errorMessage":"Missing value for --action","messagePattern":"Missing value for --action","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/welcome.js","lineNumber":27,"sourceCode":"const VALID_ACTIONS = new Set([\n  'installed',\n  'updated',\n  'configured',\n  'migrated',\n  'resumed',\n  'already-migrated',\n]);\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  }","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/welcome.js#L9-L45","documentation":"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.","triggerScenarios":"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 '--'.","commonSituations":"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.","solutions":["Pass a value directly after --action, e.g. `--action install`","Check that the shell variable holding the action is non-empty before invoking","Use space-separated form, not `--action=value`, unless the parser supports it","Run with no args or check the script's help to see valid actions"],"exampleFix":"// before\nnode scripts/welcome.js --action\n// after\nnode scripts/welcome.js --action install","handlingStrategy":"validation","validationCode":"const actionIdx = process.argv.indexOf('--action');\nconst action = actionIdx !== -1 ? process.argv[actionIdx + 1] : undefined;\nif (action === undefined || action.startsWith('--')) {\n  throw new Error('Missing value for --action');\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  const { action } = parseArgs(process.argv.slice(2));\n} catch (err) {\n  if (err.message.startsWith('Missing value for')) {\n    console.error(`Usage: welcome.js --action <${[...VALID_ACTIONS].join('|')}> [--version x.y.z]`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Always place the value immediately after the flag, space-separated","Guard shell variables: `${ACTION:?ACTION not set}` in bash before invoking","Avoid --flag=value syntax unless the parser supports it","Test CLI wrappers with empty-variable cases"],"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"}