{"record":{"id":"ea68df45f1ce57b9","repo":"stablyai/orca","slug":"trials-must-be-a-positive-integer","errorCode":null,"errorMessage":"--trials must be a positive integer","messagePattern":"--trials must be a positive integer","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/hang-watchdog-memory-benchmark.mjs","lineNumber":299,"sourceCode":"  const options = { boundary: '', trials: DEFAULT_TRIALS, output: '' }\n  for (let index = 0; index < argv.length; index += 1) {\n    const arg = argv[index]\n    const value = argv[index + 1]\n    if (arg === '--boundary' || arg === '--trials' || arg === '--output') {\n      if (!value) {\n        throw new Error(`Missing value for ${arg}`)\n      }\n      options[arg.slice(2)] = arg === '--trials' ? Number(value) : value\n      index += 1\n    } else {\n      throw new Error(`Unknown argument: ${arg}`)\n    }\n  }\n  if (!['child', 'worker'].includes(options.boundary)) {\n    throw new Error('--boundary must be child or worker')\n  }\n  if (!Number.isInteger(options.trials) || options.trials < 1) {\n    throw new Error('--trials must be a positive integer')\n  }\n  return options\n}\n\nfunction electronPath() {\n  const requirePath = import.meta.resolve('electron')\n  const electronModulePath = fileURLToPath(requirePath)\n  return execFileSync(\n    process.execPath,\n    ['-e', `process.stdout.write(require(${JSON.stringify(electronModulePath)}))`],\n    {\n      encoding: 'utf8'\n    }\n  )\n}\n\nfunction runTrial(executable, boundary) {\n  for (let attempt = 1; attempt <= MAX_LAUNCH_ATTEMPTS; attempt += 1) {","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/hang-watchdog-memory-benchmark.mjs#L281-L317","documentation":"Thrown by parseArgs when options.trials is not an integer or is less than 1. The value is coerced via Number(value); non-numeric strings become NaN, and floats/zero/negatives are rejected. Trials drive how many times runTrial is invoked for median computation.","triggerScenarios":"Passing `--trials abc`, `--trials 3.5`, `--trials 0`, or `--trials -2`. Also fires on an empty string value.","commonSituations":"Typos, passing a trial count variable that resolved to empty in CI, or misunderstanding that the value must be a positive whole number.","solutions":["Pass a positive integer: `--trials 7` (the default).","Validate the variable feeding --trials in CI before invoking the script."],"exampleFix":"// before\nnode ... --boundary child --trials 3.5\n// after\nnode ... --boundary child --trials 4","handlingStrategy":"validation","validationCode":"const trials = Number(options.trials)\nif (!Number.isInteger(trials) || trials < 1) {\n  throw new Error(`--trials must be a positive integer, got: ${options.trials}`)\n}","typeGuard":"const isPositiveInteger = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v) && v >= 1","tryCatchPattern":null,"preventionTips":["Validate CI variables feeding --trials before the script invocation.","Remember the parser uses Number(), so floats and non-numerics are rejected."],"tags":["benchmark","cli","arguments","validation","numeric"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}