{"record":{"id":"5bd5b7d18d266ab7","repo":"can1357/oh-my-pi","slug":"array-length-must-be-an-integer-in-min-array-le","errorCode":null,"errorMessage":"Array length must be an integer in [${MIN_ARRAY_LENGTH}, ${MAX_ARRAY_LENGTH}], got ${length}","messagePattern":"Array length must be an integer in \\[(.+?), (.+?)\\], got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/if-bench/actions.ts","lineNumber":41,"sourceCode":"\t| { kind: \"reverse\"; first: number; last: number }\n\t| { kind: \"move\"; from: number; to: number }\n\t| { kind: \"swap-pairs\" }\n\t| { kind: \"odd-even\" }\n\t| { kind: \"reverse-blocks\"; size: number }\n\t| { kind: \"rotate-span\"; first: number; last: number; amount: number }\n\t| { kind: \"weave\" };\n\n/**\n * Opening state: `A..Z` truncated to `length` and shuffled by a fixed LCG.\n *\n * Scrambled on purpose — an alphabetical start lets a model reconstruct state\n * from memory instead of reading its own previous answer.\n *\n * @throws when `length` is odd or outside [{@link MIN_ARRAY_LENGTH}, {@link MAX_ARRAY_LENGTH}].\n */\nexport function initialArray(length: number): string {\n\tif (!Number.isInteger(length) || length < MIN_ARRAY_LENGTH || length > MAX_ARRAY_LENGTH) {\n\t\tthrow new Error(`Array length must be an integer in [${MIN_ARRAY_LENGTH}, ${MAX_ARRAY_LENGTH}], got ${length}`);\n\t}\n\tif (length % 2 !== 0)\n\t\tthrow new Error(`Array length must be even (the weave action splits it in half), got ${length}`);\n\tconst chars = ALPHABET.slice(0, length).split(\"\");\n\tlet seed = 0x9e3779b9;\n\tfor (let i = chars.length - 1; i > 0; i -= 1) {\n\t\tseed = (Math.imul(seed, 1103515245) + 12345) >>> 0;\n\t\tconst j = seed % (i + 1);\n\t\t[chars[i], chars[j]] = [chars[j]!, chars[i]!];\n\t}\n\treturn chars.join(\"\");\n}\n\n/**\n * The `count` actions starting at absolute index `start`.\n *\n * The kind cycles every 10 indices so each turn mixes local edits (swap, move)\n * with whole-array permutations (weave, odd-even) that invalidate every","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/if-bench/actions.ts#L23-L59","documentation":"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.","triggerScenarios":"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.","commonSituations":"Typo'd CLI flag values; scripted runs interpolating unvalidated variables; experimenting with very large arrays for stress testing beyond the cap.","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"],"exampleFix":"// before\nomp if-bench opus --length 3\n// after\nomp if-bench opus --length 16","handlingStrategy":"validation","validationCode":"if (!Number.isInteger(length) || length < MIN_ARRAY_LENGTH || length > MAX_ARRAY_LENGTH) {\n  throw new Error(`--length must be an integer in [${MIN_ARRAY_LENGTH}, ${MAX_ARRAY_LENGTH}]`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runIfBenchCommand({ models, flags: { length } });\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Array length must be an integer\")) {\n    console.error(`Invalid --length; use ${MIN_ARRAY_LENGTH}-${MAX_ARRAY_LENGTH}`);\n    process.exitCode = 1;\n  } else throw err;\n}","preventionTips":["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"],"tags":["cli","validation","range-check"],"backgroundTag":"invalid-parameter-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}