{"record":{"id":"7a6d025bfca06e0b","repo":"stablyai/orca","slug":"expect-must-be-retained-or-reaped","errorCode":null,"errorMessage":"--expect must be retained or reaped","messagePattern":"--expect must be retained or reaped","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/macos-computer-helper-owner-loss-benchmark.mjs","lineNumber":406,"sourceCode":"}\n\nfunction parseArgs(argv) {\n  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'], {","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/macos-computer-helper-owner-loss-benchmark.mjs#L388-L424","documentation":"The --expect flag received a value outside the allowed set {retained, reaped}. This also fires when --expect is omitted entirely: options.expect defaults to '' (line 391), which is not in the allowed list. These are the only two expectation modes the benchmark supports.","triggerScenarios":"options.expect is not 'retained' or 'reaped' at the post-parse validation (line 405). Causes: omitting --expect entirely (defaults to ''), passing an invalid value like 'killed', or the value being accidentally consumed by a preceding flag.","commonSituations":"Forgetting to pass --expect at all; typo in the value; --expect value consumed by a prior flag that also reads the next token; copy-paste from outdated docs.","solutions":["Always pass --expect explicitly: `--expect reaped` or `--expect retained`","Ensure no preceding flag consumes the --expect value (each flag reads argv[index+1])","Check for typos: only 'retained' and 'reaped' are valid"],"exampleFix":"// before\nnode benchmark.mjs --trials 3\n// (no --expect → defaults to '' → fails validation)\n\n// after\nnode benchmark.mjs --expect reaped --trials 3","handlingStrategy":"validation","validationCode":"// Validate --expect value before running\nconst VALID_EXPECTATIONS = new Set(['retained', 'reaped'])\nconst expectIndex = argv.indexOf('--expect')\nif (expectIndex === -1) {\n  throw new Error('--expect is required (retained or reaped)')\n}\nconst expectValue = argv[expectIndex + 1]\nif (!VALID_EXPECTATIONS.has(expectValue)) {\n  throw new Error(`--expect must be 'retained' or 'reaped', got: ${expectValue}`)\n}","typeGuard":"function isExpectation(value) {\n  return value === 'retained' || value === 'reaped'\n}","tryCatchPattern":null,"preventionTips":["Always pass --expect explicitly — do not rely on a default","Document the two valid values prominently in the script's --help or README","Validate the value in wrapper scripts before delegating to the benchmark"],"tags":["cli","validation"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}