{"record":{"id":"a80044633be33d71","repo":"affaan-m/ECC","slug":"option-requires-a-non-empty-value-for-live-node","errorCode":null,"errorMessage":"${option} requires a non-empty value for live node qualification.","messagePattern":"(.+?) requires a non-empty value for live node qualification\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ito.js","lineNumber":101,"sourceCode":"\nLive node qualification requires ITO_ENABLE_SIXTYTWO_LIVE=1,\n--live-sixtytwo, an explicit node list, and an existing absolute config\ndirectory. It forwards only named SIXTYTWO_API_TOKEN/SIXTYTWO_TOKEN and SSH\nagent state; ITO_API_KEY is intentionally excluded. The canonical CLI requires\nsixtytwo-cli==0.3.33 and fails closed.\n`);\n}\n\nfunction requiredOptionValue(args, option) {\n  const indexes = args\n    .map((value, index) => (value === option ? index : -1))\n    .filter((index) => index >= 0);\n  if (indexes.length !== 1) {\n    throw new Error(`${option} is required exactly once for live node qualification.`);\n  }\n  const value = args[indexes[0] + 1];\n  if (!value?.trim() || value.startsWith(\"--\")) {\n    throw new Error(`${option} requires a non-empty value for live node qualification.`);\n  }\n  return value;\n}\n\nfunction validateNodeQualificationArgs(args, environment) {\n  if (environment.ITO_ENABLE_SIXTYTWO_LIVE !== \"1\") {\n    throw new Error(\n      \"Live node qualification requires ITO_ENABLE_SIXTYTWO_LIVE=1 before any process is started.\"\n    );\n  }\n  if (args.filter((value) => value === \"--live-sixtytwo\").length !== 1) {\n    throw new Error(\n      \"Live node qualification requires --live-sixtytwo exactly once before any process is started.\"\n    );\n  }\n  requiredOptionValue(args, \"--cluster\");\n  const nodes = requiredOptionValue(args, \"--nodes\");\n  if (!nodes.split(\",\").every((node) => node.trim().length > 0)) {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/ito.js#L83-L119","documentation":"requiredOptionValue() validates that the token following the option flag is a real, non-empty value. If the next argument is missing, blank/whitespace, or itself starts with '--' (i.e. another flag), the option has no usable value and the script throws before starting any process.","triggerScenarios":"Invoking e.g. `--nodes --cluster prod` (next token is a flag), `--nodes` at end of args, or `--nodes \"  \"` so value?.trim() is empty or value.startsWith('--') is true.","commonSituations":"Empty environment variables interpolated as the value (`--nodes \"$NODES\"` with NODES unset); forgetting the value entirely; accidental reordering that puts another flag where the value belongs.","solutions":["Provide a concrete non-empty value after the flag, e.g. --nodes node-a,node-b.","Check shell variables for emptiness before interpolation: ${NODES:?NODES must be set}.","Reorder arguments so a value — not another flag — immediately follows the option."],"exampleFix":"// before\nito --live-sixtytwo --cluster prod --nodes --live-sixtytwo\n// after\nito --live-sixtytwo --cluster prod --nodes node-a,node-b","handlingStrategy":"validation","validationCode":"const idx = args.indexOf(option); const val = args[idx + 1]; if (!val || !val.trim() || val.startsWith('--')) throw new Error(`${option} needs a non-empty value`);","typeGuard":"const hasOptionValue = (args, option) => { const i = args.indexOf(option); const v = i >= 0 ? args[i + 1] : undefined; return typeof v === 'string' && v.trim() !== '' && !v.startsWith('--'); };","tryCatchPattern":"try { runQualification(args); } catch (e) { if (e.message.includes('requires a non-empty value')) { console.error(`${e.message} — pass a real value after ${e.message.split(' ')[0]}`); process.exit(2); } throw e; }","preventionTips":["Never let an empty shell variable occupy a flag's value slot; use ${VAR:?msg}.","Inspect the fully assembled argv (set -x) when commands are composed dynamically.","Validate each flag has a following non-flag token before execution."],"tags":["cli","argument-validation","empty-value"],"backgroundTag":"invalid-flag-value","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"}