yamadashy/repomix · error · RepomixError

Invalid size: '${input}'. Resulting byte value is too large.

Error message

Invalid size: '${input}'. Resulting byte value is too large.

What it means

The final byte value (amount * 1024 or 1024*1024, floored) must be a safe integer. If the multiplication overflows the safe integer range (Number.MAX_SAFE_INTEGER), the parser throws this error because the resulting byte count cannot be represented exactly.

Source

Thrown at src/shared/sizeParse.ts:23

export const parseHumanSizeToBytes = (input: string): number => {
  const match = SIZE_RE.exec(input);
  if (!match) {
    throw new RepomixError(
      `Invalid size: '${input}'. Expected format like '500kb', '2mb', or '2.5mb' (case-insensitive).`,
    );
  }

  const amount = Number(match[1]);
  if (!Number.isFinite(amount) || amount <= 0) {
    throw new RepomixError(`Invalid size amount: '${match[1]}'. Must be a positive number.`);
  }

  const unit = match[2].toLowerCase();
  const multiplier = unit === 'kb' ? 1024 : 1024 * 1024;
  const bytes = Math.floor(amount * multiplier);

  if (!Number.isSafeInteger(bytes)) {
    throw new RepomixError(`Invalid size: '${input}'. Resulting byte value is too large.`);
  }

  return bytes;
};

View on GitHub (pinned to f465ad9093)

Solutions

  1. Use a realistic size within safe-integer bytes (under ~8 exabytes, practically any sane size like '1024mb')
  2. Omit the size option if you meant 'no limit' instead of using a huge number
  3. Check generated config for runaway numeric values

Example fix

// before
{ "output": { "truncateSize": "99999999999999mb" } }
// after
{ "output": { "truncateSize": "1024mb" } }
Defensive patterns

Strategy: validation

Validate before calling

const m = /^\s*(\d+(?:\.\d+)?)\s*(kb|mb)\s*$/i.exec(raw);
if (m) {
  const bytes = Math.floor(Number(m[1]) * (m[2].toLowerCase() === 'kb' ? 1024 : 1048576));
  if (!Number.isSafeInteger(bytes)) throw new Error(`'${raw}' is too large`);
}

Try / catch

try {
  const bytes = parseHumanSizeToBytes(raw);
} catch (e) {
  if (String(e.message).includes('too large')) {
    // clamp to a sane maximum instead of the huge value
  } else throw e;
}

Prevention

When it happens

Trigger: Passing astronomically large sizes like '99999999999mb' (≈1e17 bytes) that exceed Number.MAX_SAFE_INTEGER after unit multiplication; typically from config typos with too many digits or template interpolation gone wrong.

Common situations: Copy-paste errors producing 20+ digit numbers; attempting an 'infinite' limit with an enormous value instead of omitting the option; programmatic config generation with uninitialized/unbounded variables.

Related errors


AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29). Data as JSON: /api/errors/4120a43cc34303cf. Report an issue: GitHub.