{"record":{"id":"d9a1d31bb7c4beaa","repo":"koala73/worldmonitor","slug":"mcp-smoke-run-budget-ms-must-be-a-positive-number","errorCode":null,"errorMessage":"MCP_SMOKE_RUN_BUDGET_MS must be a positive number","messagePattern":"MCP_SMOKE_RUN_BUDGET_MS must be a positive number","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/mcp-live-smoke.mjs","lineNumber":864,"sourceCode":"  };\n  try {\n    writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\\n`, 'utf8');\n    console.log(`MCP smoke report: ${reportPath}`);\n    return true;\n  } catch (error) {\n    console.error(`Unable to write MCP smoke report: ${formatSafeError(error)}`);\n    return false;\n  }\n}\n\nasync function main() {\n  let completedAllGroups = false;\n  let reportPath = null;\n  try {\n    reportPath = reportPathFromArgs(process.argv.slice(2));\n    runBudgetMs = Number(process.env.MCP_SMOKE_RUN_BUDGET_MS ?? DEFAULT_RUN_BUDGET_MS);\n    if (!(Number.isFinite(runBudgetMs) && runBudgetMs > 0)) {\n      throw new Error('MCP_SMOKE_RUN_BUDGET_MS must be a positive number');\n    }\n    runDeadlineAt = Date.now() + runBudgetMs;\n\n    console.log('\\n── canonical ──');\n    for (const host of HOSTS) {\n      await walkHost(host);\n      stopIfRunBudgetExhausted();\n      await probeDiscovery(host);\n      stopIfRunBudgetExhausted();\n    }\n    completeGroup('canonical');\n\n    console.log('\\n── aliases ──');\n    for (const host of ALIAS_HOSTS) {\n      await probeAliasMigration(host);\n      stopIfRunBudgetExhausted();\n    }\n    completeGroup('aliases');","sourceCodeStart":846,"sourceCodeEnd":882,"githubUrl":"https://github.com/koala73/worldmonitor/blob/e586b8b4b80f595aa7ece295eec10d76f2921240/scripts/mcp-live-smoke.mjs#L846-L882","documentation":"The smoke script reads MCP_SMOKE_RUN_BUDGET_MS to set a run deadline. If the value is not a finite number greater than 0 (including unset-but-present empty strings or non-numeric strings), it throws 'MCP_SMOKE_RUN_BUDGET_MS must be a positive number'. Number() of a non-numeric string is NaN, which fails the guard.","triggerScenarios":"Exporting MCP_SMOKE_RUN_BUDGET_MS=\"abc\" (NaN), \"0\", \"-5000\", or \"\" (empty string coerces to 0), then running the script.","commonSituations":"CI secrets or .env files with an empty or mistyped value; quoting mistakes like MCP_SMOKE_RUN_BUDGET_MS=\"30 000\"; unit confusion (passing seconds instead of milliseconds like \"30\").","solutions":["Set MCP_SMOKE_RUN_BUDGET_MS to a positive integer in milliseconds, e.g. 600000","Unset the variable to fall back to DEFAULT_RUN_BUDGET_MS","Fix non-numeric characters (spaces, units) in the value"],"exampleFix":"// before\nexport MCP_SMOKE_RUN_BUDGET_MS=\"\"\n// after\nexport MCP_SMOKE_RUN_BUDGET_MS=600000","handlingStrategy":"validation","validationCode":"const raw = process.env.MCP_SMOKE_RUN_BUDGET_MS;\nconst ms = raw === undefined ? undefined : Number(raw);\nif (ms !== undefined && !(Number.isFinite(ms) && ms > 0)) throw new Error(`MCP_SMOKE_RUN_BUDGET_MS must be a positive number, got ${JSON.stringify(raw)}`);","typeGuard":"const isPositiveNumber = (v) => typeof v === 'number' && Number.isFinite(v) && v > 0;","tryCatchPattern":"try {\n  runBudgetMs = Number(process.env.MCP_SMOKE_RUN_BUDGET_MS ?? DEFAULT_RUN_BUDGET_MS);\n  if (!(Number.isFinite(runBudgetMs) && runBudgetMs > 0)) throw new Error('MCP_SMOKE_RUN_BUDGET_MS must be a positive number');\n} catch (err) {\n  console.error(`${err.message}; using default ${DEFAULT_RUN_BUDGET_MS}ms`);\n}","preventionTips":["Set the value as a plain positive integer of milliseconds","Never leave the env var empty-string in CI or .env files","Validate env values in CI before running the smoke script"],"tags":["env","configuration","smoke-test"],"backgroundTag":"invalid-env-var-value","analyzedSha":"e586b8b4b80f595aa7ece295eec10d76f2921240","analyzedAt":"2026-09-22T01:50:49.965Z","contentChangedAt":"2026-09-22T01:50:49.965Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}