{"record":{"id":"3b76e16ffef0f899","repo":"tinyhumansai/openhuman","slug":"label-must-be-a-positive-integer-3b76e1","errorCode":null,"errorMessage":"${label} must be a positive integer","messagePattern":"(.+?) must be a positive integer","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/debug/harness-subagent-rpc-audit.mjs","lineNumber":163,"sourceCode":"  ]);\n  if (!scenarios.has(opts.scenario)) {\n    throw new Error(\n      `--scenario must be one of ${Array.from(scenarios).join(\", \")}`,\n    );\n  }\n  const providerModes = new Set([\"direct-openai\", \"openhuman-backend\"]);\n  if (!providerModes.has(opts.providerMode)) {\n    throw new Error(\n      `--provider-mode must be one of ${Array.from(providerModes).join(\", \")}`,\n    );\n  }\n  return opts;\n}\n\nfunction parsePositiveInt(raw, label) {\n  const value = Number(raw);\n  if (!Number.isInteger(value) || value < 1) {\n    throw new Error(`${label} must be a positive integer`);\n  }\n  return value;\n}\n\nfunction defaultOpenhumanDir() {\n  return process.env.OPENHUMAN_APP_ENV === \"staging\"\n    ? path.join(homedir(), \".openhuman-staging\")\n    : path.join(homedir(), \".openhuman\");\n}\n\nasync function defaultWorkspace() {\n  if (process.env.OPENHUMAN_WORKSPACE) return process.env.OPENHUMAN_WORKSPACE;\n  const openhumanDir = defaultOpenhumanDir();\n  try {\n    const active = await readFile(\n      path.join(openhumanDir, \"active_user.toml\"),\n      \"utf8\",\n    );","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/scripts/debug/harness-subagent-rpc-audit.mjs#L145-L181","documentation":"parsePositiveInt() guards the numeric flags of harness-subagent-rpc-audit (--rpc-timeout-ms, --spawn-wait-ms, --settle-wait-ms). Number(raw) must be an integer >= 1; zero, negatives, decimals, NaN (non-numeric strings) and Infinity all fail, with the flag's own name in the message.","triggerScenarios":"`--spawn-wait-ms 0`, `--rpc-timeout-ms -1`, a float like `--settle-wait-ms 500.5`, a non-numeric string (`--rpc-timeout-ms 10s`), or an unquoted/empty shell expansion that yields an empty string.","commonSituations":"Unit confusion (passing seconds where ms is expected and fat-fingering 0); scripting the call with computed values that can be empty or NaN on edge cases.","solutions":["Pass a positive integer number of milliseconds, at least 1","Strip units before passing (`10s` → `10000`)","If the value is computed, default it in the caller: `WAIT=${WAIT:-120000}`"],"exampleFix":"# before\nnode scripts/debug/harness-subagent-rpc-audit.mjs --spawn-wait-ms 0\n\n# after\nnode scripts/debug/harness-subagent-rpc-audit.mjs --spawn-wait-ms 120000","handlingStrategy":"validation","validationCode":"function toPositiveIntMs(raw, label) {\n  const n = Number(raw);\n  if (!Number.isInteger(n) || n < 1) {\n    console.error(`${label} must be a positive integer (ms)`); process.exit(2);\n  }\n  return n;\n}","typeGuard":"function isPositiveInt(v) {\n  const n = Number(v);\n  return Number.isInteger(n) && n >= 1;\n}","tryCatchPattern":null,"preventionTips":["Compute wait values with a floor: Math.max(1000, Number(WAIT) || 0)","Strip unit suffixes before passing (10s -> 10000)"],"tags":["cli","validation","arguments","numbers"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}