can1357/oh-my-pi · error · Error

-- 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.

Solutions

  1. Pass a whole number >= 1: --samples 10 --concurrency 4
  2. Omit the flag entirely to use the built-in fallback instead of passing 0
  3. Check the interpolated flag name in the message and fix that specific --flag
  4. 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

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`.

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/b398ef1bcd63007c. Report an issue: GitHub.

Appendix: 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)