yamadashy/repomix · error · RepomixError
Invalid size: '${input}'. Expected format like '500kb', '2mb
Error message
Invalid size: '${input}'. Expected format like '500kb', '2mb', or '2.5mb' (case-insensitive). What it means
parseHumanSizeToBytes parses human-readable size strings strictly matching /^\s*(\d+(?:\.\d+)?)\s*(kb|mb)\s*$/i. If the input doesn't match (wrong unit, no unit, negative, unsupported units like gb/b), it throws a RepomixError explaining the accepted format.
Source
Thrown at src/shared/sizeParse.ts:8
import { RepomixError } from './errorHandle.js';
const SIZE_RE = /^\s*(\d+(?:\.\d+)?)\s*(kb|mb)\s*$/i;
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
- Convert the value to kb or mb, e.g. '1gb' -> '1024mb', raw bytes -> '50mb'
- Match the format exactly: number plus kb/mb, e.g. '500kb', '2.5mb'
- Fix typos (letters swapped for digits) in the size string
Example fix
// before
{ "output": { "truncateSize": "1gb" } }
// after
{ "output": { "truncateSize": "1024mb" } } Defensive patterns
Strategy: validation
Validate before calling
const SIZE_RE = /^\s*(\d+(?:\.\d+)?)\s*(kb|mb)\s*$/i;
if (!SIZE_RE.test(raw)) throw new Error(`'${raw}' must look like '500kb' or '2.5mb'`); Try / catch
import { parseHumanSizeToBytes } from 'repomix/shared';
try {
const bytes = parseHumanSizeToBytes(raw);
} catch (e) {
if (String(e.message).startsWith('Invalid size:')) {
// normalize to kb/mb before writing into config
} else throw e;
} Prevention
- Always express sizes in kb or mb ('1gb' -> '1024mb')
- Validate size strings when generating config programmatically
- Never pass bare byte counts or MiB units
When it happens
Trigger: Passing size config values (e.g. file-size limits) like '1gb', '500KB/s', 'kb' with no number, '1 B', '2 MB ' with tab handling okay but '2mib' wrong, or a plain integer without unit.
Common situations: Users copy sizes from other tools that accept gb or bytes ('52428800'); typos like '5OOkb'; assuming decimal suffixes (MiB) or byte-only input are supported.
Related errors
- Invalid size amount: '${match[1]}'. Must be a positive numbe
- Invalid size: '${input}'. Resulting byte value is too large.
- In remote mode, --config must be an absolute path to avoid l
- Config file not found at ${argConfigPath}
- Unsupported config file format: ${filePath}
AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29).
Data as JSON: /api/errors/8e395d20df086313.
Report an issue: GitHub.