{"record":{"id":"77597d3d55f4626f","repo":"stablyai/orca","slug":"name-requires-a-positive-integer","errorCode":null,"errorMessage":"${name} requires a positive integer.","messagePattern":"(.+?) requires a positive integer\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/repro-windows-apphang-terminal-activation.mjs","lineNumber":111,"sourceCode":"  node config/scripts/repro-windows-apphang-terminal-activation.mjs [options]\n\nOptions:\n  --expect=none|repro|pass       none prints measurements, repro exits 0 only when hang evidence is observed,\n                                 pass exits 1 if hang evidence is observed. Default: none.\n  --gpu=on|off|auto[,mode...]    Terminal GPU setting(s) to run. Default: on.\n  --cycles=N                     Activation/output cycles per GPU mode. Default: ${defaultCycles}.\n  --output-lines=N               Lines emitted by each terminal stress command. Default: ${defaultOutputLines}.\n  --report=PATH                  Write full JSON evidence to PATH and print a compact summary to stdout.\n  --distro=NAME                  WSL distro to use. Default: first non docker-desktop distro.\n  --no-source-control            Do not open Source Control during the stress loop.\n  --no-dead-pty-reactivate       Do not kill PTYs and revisit workspaces after initial activation.\n  --keep                         Keep disposable WSL/userData fixtures after the run.`)\n}\n\nfunction parsePositiveInt(name, value) {\n  const parsed = Number.parseInt(value ?? '', 10)\n  if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== value) {\n    throw new Error(`${name} requires a positive integer.`)\n  }\n  return parsed\n}\n\nasync function main() {\n  if (process.platform !== 'win32') {\n    throw new Error('This repro harness is intentionally Windows-only.')\n  }\n  const args = parseArgs()\n  const distros = listWslDistros()\n  const distro = args.distro ?? distros[0]\n  if (!distro) {\n    throw new Error('No user WSL distro found. Install/enable WSL or pass --distro=NAME.')\n  }\n  console.log(\n    `[apphang-repro] issue=https://github.com/stablyai/orca/issues/6874 distro=${distro} gpuModes=${args.gpuModes.join(',')} cycles=${args.cycles}`\n  )\n  const fixture = createWslFixture(distro)","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/repro-windows-apphang-terminal-activation.mjs#L93-L129","documentation":"Thrown by parsePositiveInt() in the apphang repro harness when --cycles or --output-lines is not a canonical positive integer string. The check is strict: Number.parseInt must succeed, the result must be > 0, and String(parsed) must exactly equal the input (rejecting leading zeros, whitespace, decimals, and suffixes).","triggerScenarios":"Passing --cycles=0, --cycles=-5, --cycles=3.5, --cycles=08, --cycles=10abc, or --output-lines= (empty). The String(parsed) !== value guard catches non-canonical forms that parseInt would silently accept.","commonSituations":"A developer passes a padded value like 014, or appends a unit like 1000ms, or sets cycles to 0 to skip.","solutions":["Pass a plain positive integer with no padding or suffixes, e.g. --cycles=20.","Use the defaults by omitting the flag (cycles=14, output-lines=1600)."],"exampleFix":"// before\nnode config/scripts/repro-windows-apphang-terminal-activation.mjs --cycles=08\n// after\nnode config/scripts/repro-windows-apphang-terminal-activation.mjs --cycles=8","handlingStrategy":"validation","validationCode":"function parsePositiveInt(name, value) {\n  const parsed = Number.parseInt(value ?? '', 10)\n  if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== value) {\n    throw new Error(`${name} requires a positive integer.`)\n  }\n  return parsed\n}","typeGuard":"function isCanonicalPositiveIntString(value) {\n  if (typeof value !== 'string') return false\n  const parsed = Number.parseInt(value, 10)\n  return Number.isInteger(parsed) && parsed > 0 && String(parsed) === value\n}","tryCatchPattern":null,"preventionTips":["The String(parsed) !== value check rejects padded/whitespace/suffixed values — pass bare digits only.","Reuse the same parsePositiveInt helper for all integer flags to keep validation uniform."],"tags":["cli","validation","argument-parsing","integer-parse"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}