can1357/oh-my-pi · error

${flag} must be a positive integer

Error message

${flag} must be a positive integer

What it means

parseArgs validates --attempts, --concurrency, and --epochs: each must be an integer >= 1. Non-integers (floats, NaN from a non-numeric string) or values below 1 throw this error naming the offending flag.

Source

Thrown at packages/metaharness/src/tb/cli.ts:211

				config.help = true;
				break;
			default:
				throw new Error(`unknown option: ${arg}`);
		}
	}

	if (config.help) return config;
	if (config.models.length === 0) throw new Error("at least one --model is required");
	for (const model of config.models) {
		const slash = model.indexOf("/");
		if (slash <= 0 || slash === model.length - 1) throw new Error(`invalid model ${model}; expected provider/model`);
	}
	for (const [flag, value] of [
		["--attempts", config.attempts],
		["--concurrency", config.concurrency],
		["--epochs", config.epochs],
	] as const) {
		if (!Number.isInteger(value) || value < 1) throw new Error(`${flag} must be a positive integer`);
	}
	if (config.budget !== null && (!Number.isFinite(config.budget) || config.budget < 0)) {
		throw new Error("--budget must be a non-negative number");
	}
	return config;
}

class Semaphore {
	#available: number;
	#queue: Array<() => void> = [];

	constructor(available: number) {
		this.#available = available;
	}

	async acquire(): Promise<void> {
		if (this.#available > 0) {
			this.#available--;

View on GitHub (pinned to 9690622007)

Solutions

  1. Pass a whole number >= 1 for the named flag
  2. Remove units/suffixes from the value (3 not 3x)
  3. Check the shell variable actually contains a number

Example fix

// before
$ tb --epochs 0 --model x/y
// after
$ tb --epochs 1 --model x/y
Defensive patterns

Strategy: validation

Validate before calling

const isPositiveInt = (v: unknown): v is number =>
  typeof v === "number" && Number.isInteger(v) && v >= 1;
if (!isPositiveInt(epochs)) throw new Error("--epochs must be >= 1");

Type guard

const isPositiveInt = (v: unknown): v is number =>
  typeof v === "number" && Number.isInteger(v) && v >= 1;

Try / catch

try {
  config = parseArgs(args);
} catch (err) {
  if (String(err.message).endsWith("must be a positive integer")) {
    console.error(`${err.message} — pass a whole number >= 1`);
    process.exit(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: --attempts 0, --concurrency 2.5, --epochs abc (parses to NaN), or a negative number; also values supplied via inline `--epochs=0` form.

Common situations: Shell variables that are empty or contain units ('3x'); copy-pasted fractional values; misunderstanding that 0 means 'unlimited' (it does not — minimum is 1).

Related errors


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