{"record":{"id":"4f851c354e38121f","repo":"stablyai/orca","slug":"missing-value-for-arg-4f851c","errorCode":null,"errorMessage":"Missing value for ${arg}","messagePattern":"Missing value for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/macos-computer-helper-owner-loss-benchmark.mjs","lineNumber":397,"sourceCode":"      abruptExitMs: abruptExitMs === null ? null : Math.round(abruptExitMs),\n      postLossRssBytes,\n      gracefulExitMs\n    }\n  } finally {\n    invalidPeer?.destroy()\n    sidecar?.child.kill('SIGKILL')\n    await stopProcess(helper)\n  }\n}\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'))","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/macos-computer-helper-owner-loss-benchmark.mjs#L379-L415","documentation":"CLI argument parser rejects --expect, --trials, or --output when no value follows. The parser reads argv[index+1] as the value; if it is undefined (flag is the last token) or an empty string, the check at line 396 (!value) fires. Note: if the next token is another flag like --trials, it is truthy and gets consumed as the value instead, producing a different error downstream.","triggerScenarios":"The flag is the last token in argv (e.g., `node benchmark.mjs --expect` with nothing after it), or the shell passes an empty string as the next token. argv[index+1] is undefined or ''.","commonSituations":"Shell quoting error drops the value (e.g., --expect $UNSET_VAR where the var is empty); script wrapper truncates args; copy-paste from docs omits the value; the flag is accidentally placed at the end of a concatenated command.","solutions":["Provide a value immediately after the flag: `--expect reaped`","Check shell variable expansion — ensure the variable is set and non-empty before interpolation","Quote the entire argument pair if constructing the command programmatically"],"exampleFix":"// before\nnode benchmark.mjs --expect\n\n// after\nnode benchmark.mjs --expect reaped","handlingStrategy":"validation","validationCode":"// Validate argv before parseArgs\nconst KNOWN_FLAGS = ['--expect', '--trials', '--output']\nfor (let i = 0; i < argv.length; i++) {\n  if (KNOWN_FLAGS.includes(argv[i])) {\n    if (!argv[i + 1]) {\n      throw new Error(`${argv[i]} requires a value — check shell quoting`)\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide a value immediately after each flag","Check shell variable expansion — ensure env vars are set before interpolation","Use a proper argument parser (commander, yargs) that handles missing values with clearer messages"],"tags":["cli","argument-parsing"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}