can1357/oh-my-pi · error
Array length must be an integer in [${MIN_ARRAY_LENGTH}, ${M
Error message
Array length must be an integer in [${MIN_ARRAY_LENGTH}, ${MAX_ARRAY_LENGTH}], got ${length} What it means
if-bench's initialArray() builds a deterministic pseudo-random string of a given length. It validates that length is an integer within [MIN_ARRAY_LENGTH, MAX_ARRAY_LENGTH] and throws this RangeError-style Error otherwise.
Source
Thrown at packages/coding-agent/src/if-bench/actions.ts:41
| { kind: "reverse"; first: number; last: number }
| { kind: "move"; from: number; to: number }
| { kind: "swap-pairs" }
| { kind: "odd-even" }
| { kind: "reverse-blocks"; size: number }
| { kind: "rotate-span"; first: number; last: number; amount: number }
| { kind: "weave" };
/**
* Opening state: `A..Z` truncated to `length` and shuffled by a fixed LCG.
*
* Scrambled on purpose — an alphabetical start lets a model reconstruct state
* from memory instead of reading its own previous answer.
*
* @throws when `length` is odd or outside [{@link MIN_ARRAY_LENGTH}, {@link MAX_ARRAY_LENGTH}].
*/
export function initialArray(length: number): string {
if (!Number.isInteger(length) || length < MIN_ARRAY_LENGTH || length > MAX_ARRAY_LENGTH) {
throw new Error(`Array length must be an integer in [${MIN_ARRAY_LENGTH}, ${MAX_ARRAY_LENGTH}], got ${length}`);
}
if (length % 2 !== 0)
throw new Error(`Array length must be even (the weave action splits it in half), got ${length}`);
const chars = ALPHABET.slice(0, length).split("");
let seed = 0x9e3779b9;
for (let i = chars.length - 1; i > 0; i -= 1) {
seed = (Math.imul(seed, 1103515245) + 12345) >>> 0;
const j = seed % (i + 1);
[chars[i], chars[j]] = [chars[j]!, chars[i]!];
}
return chars.join("");
}
/**
* The `count` actions starting at absolute index `start`.
*
* The kind cycles every 10 indices so each turn mixes local edits (swap, move)
* with whole-array permutations (weave, odd-even) that invalidate everyView on GitHub (pinned to 9690622007)
Solutions
- Use a --length value within the documented [MIN_ARRAY_LENGTH, MAX_ARRAY_LENGTH] range
- Ensure the value parses as an integer (no decimals, no suffixes like 1k)
- Omit --length to use DEFAULT_ARRAY_LENGTH
Example fix
// before omp if-bench opus --length 3 // after omp if-bench opus --length 16
Defensive patterns
Strategy: validation
Validate before calling
if (!Number.isInteger(length) || length < MIN_ARRAY_LENGTH || length > MAX_ARRAY_LENGTH) {
throw new Error(`--length must be an integer in [${MIN_ARRAY_LENGTH}, ${MAX_ARRAY_LENGTH}]`);
} Try / catch
try {
await runIfBenchCommand({ models, flags: { length } });
} catch (err) {
if (err instanceof Error && err.message.startsWith("Array length must be an integer")) {
console.error(`Invalid --length; use ${MIN_ARRAY_LENGTH}-${MAX_ARRAY_LENGTH}`);
process.exitCode = 1;
} else throw err;
} Prevention
- Validate CLI numbers with Number.parseInt and check range before invoking
- Clamp user-supplied lengths into the supported range
- Prefer the default (omit --length) unless a specific size is required
When it happens
Trigger: Running `omp if-bench --length N` where N is non-integer, below MIN_ARRAY_LENGTH, or above MAX_ARRAY_LENGTH; passing --length 0, negative values, or a float.
Common situations: Typo'd CLI flag values; scripted runs interpolating unvalidated variables; experimenting with very large arrays for stress testing beyond the cap.
Understand the failure class
Background: "must be positive", "Invalid value": how libraries reject invalid parameter values (ValueError, ArgumentError, INVALID_PARAMETER_VALUE) — this error's family across 28 libraries.
Related errors
- invalid {} argument: {}
- invalid Zero increment value: {}
- --agents must be a positive integer
- --trusted-extension requires a non-empty, non-flag value
- --trusted-extension requires an absolute path: ${trustedPath
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/5bd5b7d18d266ab7.
Report an issue: GitHub.