{"record":{"id":"67d38e579d4f2df5","repo":"affaan-m/ECC","slug":"timeout-ms-must-be-a-positive-number","errorCode":null,"errorMessage":"--timeout-ms must be a positive number","messagePattern":"--timeout-ms must be a positive number","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ci/supply-chain-advisory-sources.js","lineNumber":387,"sourceCode":"function parseArgs(argv) {\n  const options = {};\n  for (let i = 0; i < argv.length; i += 1) {\n    const arg = argv[i];\n    if (arg === '--help' || arg === '-h') {\n      options.help = true;\n    } else if (arg === '--json') {\n      options.json = true;\n    } else if (arg === '--refresh') {\n      options.refresh = true;\n    } else if (arg === '--strict-refresh') {\n      options.strictRefresh = true;\n      options.refresh = true;\n    } else if (arg === '--generated-at') {\n      options.generatedAt = argv[++i];\n    } else if (arg === '--timeout-ms') {\n      options.timeoutMs = Number(argv[++i]);\n      if (!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0) {\n        throw new Error('--timeout-ms must be a positive number');\n      }\n    } else if (arg === '--write') {\n      options.writePath = argv[++i];\n      if (!options.writePath) throw new Error('--write requires a path');\n    } else {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n  }\n  return options;\n}\n\nfunction printHelp() {\n  console.log(`Usage: node scripts/ci/supply-chain-advisory-sources.js [options]\n\nBuild the active supply-chain advisory source report used by the scheduled\nwatch workflow and Linear ITO-57 status updates.\n\nOptions:","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/ci/supply-chain-advisory-sources.js#L369-L405","documentation":"`parseArgs` in supply-chain-advisory-sources.js reads `--timeout-ms <value>`, converts it via `Number(...)`, and validates with `!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0`. If the value is non-numeric, NaN, Infinity, zero, or negative, it throws `--timeout-ms must be a positive number`. This guards the HTTP fetch timeout used when refreshing advisory sources.","triggerScenarios":"Triggered by `--timeout-ms 0`, `--timeout-ms -5`, `--timeout-ms abc`, `--timeout-ms Infinity`, or omitting the value entirely (`--timeout-ms` as the last arg yields `Number(undefined)` = NaN). Also fires for `--timeout-ms` with an empty-string value (Number(\"\") = 0).","commonSituations":"A CI workflow passes `--timeout-ms` without a value (trailing flag). A script interpolates an empty/unset env var. A user types `--timeout-ms=5000` (the parser expects a space-separated value, so `=5000` is read as NaN). A negative or zero value is configured to mean 'no timeout'.","solutions":["Pass a positive integer in milliseconds, space-separated: `--timeout-ms 30000`.","Do not use `=` syntax — this parser consumes the next argv element, so `--timeout-ms=30000` is parsed as NaN.","If the value comes from an env var, default it when unset: `--timeout-ms ${TIMEOUT_MS:-30000}`.","Confirm the flag is not the last token on the command line (it needs a following value)."],"exampleFix":"// before — '=' syntax (parser reads next arg as NaN) and zero value\nnode scripts/ci/supply-chain-advisory-sources.js --timeout-ms=30000\nnode scripts/ci/supply-chain-advisory-sources.js --timeout-ms 0\n// -> --timeout-ms must be a positive number\n\n// after — space-separated positive integer\nnode scripts/ci/supply-chain-advisory-sources.js --timeout-ms 30000","handlingStrategy":"validation","validationCode":"function parseTimeout(argv) {\n  const i = argv.indexOf('--timeout-ms');\n  if (i === -1) return null;\n  const raw = argv[i + 1];\n  if (raw === undefined) throw new Error('--timeout-ms requires a value');\n  const n = Number(raw);\n  if (!Number.isFinite(n) || n <= 0) {\n    throw new Error(`--timeout-ms must be a positive number, got: ${raw}`);\n  }\n  return n;\n}","typeGuard":"function isPositiveMillis(raw) {\n  const n = Number(raw);\n  return Number.isFinite(n) && n > 0;\n}","tryCatchPattern":"try {\n  parseArgs(argv);\n} catch (error) {\n  if (/--timeout-ms must be a positive number/i.test(error.message)) {\n    console.error('Pass a positive integer, space-separated: --timeout-ms 30000');\n    console.error('Do not use = syntax; do not pass 0, negative, or non-numeric values.');\n  }\n  throw error;\n}","preventionTips":["Always pass --timeout-ms as two tokens: `--timeout-ms 30000`. The parser reads the next argv element, so `--timeout-ms=30000` fails.","Never let the flag be the last token without a value — `Number(undefined)` is NaN.","When sourcing the value from an env var, default it: `--timeout-ms ${TIMEOUT_MS:-30000}`.","Reject zero/negative — they are not meaningful timeouts for this fetch."],"tags":["ci","supply-chain","cli","argument-validation","timeout"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}