{"record":{"id":"d5a42d3590e153e6","repo":"stablyai/orca","slug":"trials-must-be-a-positive-integer-d5a42d","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/macos-computer-helper-owner-loss-benchmark.mjs","lineNumber":409,"sourceCode":"  const options = { expect: '', 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 === '--expect' || 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 (!['retained', 'reaped'].includes(options.expect)) {\n    throw new Error('--expect must be retained or reaped')\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 electronModulePath = fileURLToPath(import.meta.resolve('electron'))\n  return execFileSync(\n    process.execPath,\n    ['-e', `process.stdout.write(require(${JSON.stringify(electronModulePath)}))`],\n    { encoding: 'utf8' }\n  )\n}\n\nfunction buildArtifacts() {\n  execFileSync('pnpm', ['exec', 'electron-vite', 'build'], {\n    cwd: repoRoot,\n    stdio: 'inherit'\n  })","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/macos-computer-helper-owner-loss-benchmark.mjs#L391-L427","documentation":"The --trials value fails Number.isInteger() or is less than 1. The default is DEFAULT_TRIALS (3), so this only fires when --trials is explicitly provided with an invalid value. Floats, zero, negatives, NaN, and non-numeric strings all fail.","triggerScenarios":"options.trials is not a positive integer at line 408. Number('2.5') = 2.5 (not integer), Number('0') = 0 (< 1), Number('abc') = NaN (not finite → not integer), Number('-1') = -1 (< 1).","commonSituations":"Passing a float like --trials 2.5; passing zero or negative; passing a non-numeric string; shell arithmetic producing a float.","solutions":["Pass a positive integer: `--trials 3`","If computing trials programmatically, use Math.floor and clamp to >= 1 before passing"],"exampleFix":"// before\nnode benchmark.mjs --expect reaped --trials 2.5\n\n// after\nnode benchmark.mjs --expect reaped --trials 3","handlingStrategy":"validation","validationCode":"// Validate --trials before parsing\nconst trialsIndex = argv.indexOf('--trials')\nif (trialsIndex !== -1) {\n  const n = Number(argv[trialsIndex + 1])\n  if (!Number.isInteger(n) || n < 1) {\n    throw new Error(`--trials must be a positive integer, got: ${argv[trialsIndex + 1]}`)\n  }\n}","typeGuard":"function isPositiveInteger(value) {\n  return Number.isInteger(value) && value >= 1\n}","tryCatchPattern":null,"preventionTips":["Pass an integer literal, not a float or expression","If computing trials programmatically, use Math.floor and Math.max(1, ...)","Validate in wrapper scripts before delegating"],"tags":["cli","validation"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}