{"record":{"id":"116965fd407bedee","repo":"can1357/oh-my-pi","slug":"expected-name-to-be-a-positive-integer-got","errorCode":null,"errorMessage":"Expected --${name} to be a positive integer, got ${value}","messagePattern":"Expected --(.+?) to be a positive integer, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/bench-cli.ts","lineNumber":271,"sourceCode":"\twriteStderr?: (text: string) => void;\n\tsetExitCode?: (code: number) => void;\n\tstreamSimple?: StreamSimpleFn;\n\tnow?: () => number;\n\t/** Uniform [0,1) source for challenge randomization; default `Math.random`. */\n\trandom?: () => number;\n\treadTextFile?: (path: string, maxBytes: number) => Promise<string>;\n\tstdoutIsTTY?: boolean;\n}\n\nfunction getErrorMessage(error: unknown): string {\n\tif (error instanceof Error && error.message) return error.message;\n\treturn String(error);\n}\n\nfunction normalizePositiveInteger(name: string, value: number | undefined, fallback: number): number {\n\tif (value === undefined) return fallback;\n\tif (!Number.isInteger(value) || value <= 0) {\n\t\tthrow new Error(`Expected --${name} to be a positive integer, got ${value}`);\n\t}\n\treturn value;\n}\n\nfunction closeProviderSessionStates(providerSessionState: Map<string, ProviderSessionState>): void {\n\tfor (const state of providerSessionState.values()) {\n\t\tstate.close();\n\t}\n\tproviderSessionState.clear();\n}\n\nfunction isFirstTokenEvent(event: AssistantMessageEvent): boolean {\n\tswitch (event.type) {\n\t\tcase \"text_delta\":\n\t\tcase \"thinking_delta\":\n\t\tcase \"toolcall_delta\":\n\t\t\treturn event.delta.length > 0;\n\t\tcase \"text_end\":","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/bench-cli.ts#L253-L289","documentation":"normalizePositiveInteger validates bench CLI numeric flags (--runs, --max-tokens, --par, --cache-pairs, --cache-bytes, --cache-concurrency). It throws when a provided value is not a positive integer (non-integer or <= 0). Fallbacks apply only when the flag is omitted.","triggerScenarios":"Passing e.g. `--par 0`, `--runs -1`, `--cache-concurrency 2.5`, or a non-numeric string coerced to NaN to `omp bench`.","commonSituations":"Typing `--par 0` expecting unlimited; copy-pasting fractional values; scripts computing values that become 0 or NaN.","solutions":["Pass a positive whole number for the flag (>= 1).","Remove the flag to use the built-in default fallback.","Fix the generating script so it computes a valid integer."],"exampleFix":"// before\nomp bench --runs 0\n// after\nomp bench --runs 5","handlingStrategy":"validation","validationCode":"function parsePositiveInt(raw: string): number {\n  const n = Number(raw);\n  if (!Number.isInteger(n) || n <= 0) throw new Error(`--flag must be a positive integer, got ${raw}`);\n  return n;\n}","typeGuard":"function isPositiveInt(v: unknown): v is number {\n  return typeof v === \"number\" && Number.isInteger(v) && v > 0;\n}","tryCatchPattern":"try {\n  await runBenchCommand(command);\n} catch (err) {\n  if (String(err).startsWith(\"Expected --\")) {\n    console.error(\"All numeric bench flags must be integers >= 1\");\n  }\n  process.exitCode = 1;\n}","preventionTips":["Validate numeric args in wrapper scripts before invoking omp bench","Avoid computing flags with expressions that can yield 0/NaN","Check `omp bench --help` for flag defaults"],"tags":["cli","validation","arguments"],"backgroundTag":"invalid-flag-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}