can1357/oh-my-pi · error · Error
--${name} must be a positive integer
Error message
--${name} must be a positive integer What it means
normalizePositiveInteger validates the --samples and --concurrency flags of the `omp dry-balance` command. A value is rejected unless it is an integer strictly greater than zero. The flag name is interpolated into the message so you know which flag was bad.
Source
Thrown at packages/coding-agent/src/cli/dry-balance-cli.ts:201
}
type DryBalanceBenchTarget =
| {
ok: true;
account: string;
accessToken: string;
credentialId?: number;
}
| {
ok: false;
account: string;
error: string;
};
function normalizePositiveInteger(name: string, value: number | undefined, fallback: number): number {
const resolved = value ?? fallback;
if (!Number.isInteger(resolved) || resolved <= 0) {
throw new Error(`--${name} must be a positive integer`);
}
return resolved;
}
function getErrorMessage(error: unknown): string {
if (error instanceof Error && error.message) return error.message;
const message = String(error);
return message ? message : "Unknown error";
}
function extractAccount(access: {
email?: string;
accountId?: string;
projectId?: string;
enterpriseUrl?: string;
orgId?: string;
orgName?: string;
}): string {View on GitHub (pinned to 9690622007)
Solutions
- Pass a whole number >= 1: --samples 10 --concurrency 4
- Omit the flag entirely to use the built-in fallback instead of passing 0
- Check the interpolated flag name in the message and fix that specific --flag
- Quote numeric shell variables: --samples "$N" and confirm $N is a positive integer (echo "$N")
Example fix
// before omp dry-balance --samples 0 // after omp dry-balance --samples 10 --concurrency 4
Defensive patterns
Strategy: validation
Validate before calling
function assertPositiveInt(name, v) {
if (v !== undefined && (!Number.isInteger(v) || v <= 0))
throw new Error(`--${name} must be a positive integer`);
}
assertPositiveInt('samples', samples); assertPositiveInt('concurrency', concurrency); Type guard
const isPositiveInt = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v) && v > 0;
Try / catch
try {
await runDryBalance({ samples, concurrency });
} catch (e) {
if (/must be a positive integer/.test((e as Error).message)) {
console.error('Pass whole numbers >= 1, e.g. --samples 10 --concurrency 4');
} else throw e;
} Prevention
- Never pass 0 expecting 'auto' — omit the flag to use fallbacks
- Avoid floats and locale-formatted numbers (1,000); use plain integers
- Quote shell variables feeding these flags and verify they are numeric
When it happens
Trigger: Running dry-balance with `--samples 0`, `--samples -3`, `--samples 2.5`, or a non-numeric string that the flag parser coerced to NaN/undefined-outside-fallback. Only flags explicitly passed (or non-positive fallbacks) reach this check.
Common situations: Typing `--samples 0` expecting 'unlimited' or 'auto'; passing a float like `--concurrency 1.5`; shell variable interpolation producing an empty or negative value; copy-pasting a locale-formatted number like `1,000`.
Related errors
- unknown file type: {value}
- invalid size: {value}
- 2
- invalid --block-size argument '{0}'
- invalid --time-style argument {} Possible values are: - [p
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/b398ef1bcd63007c.
Report an issue: GitHub.