yamadashy/repomix · error · RepomixError
Invalid maxBytesPerPart: ${maxBytesPerPart}
Error message
Invalid maxBytesPerPart: ${maxBytesPerPart} What it means
generateSplitOutputParts validates that `maxBytesPerPart` is a positive safe integer before splitting output into parts; any other value (0, negative, NaN, Infinity, fractional, or non-numeric) throws this RepomixError. It is an argument-contract guard protecting the split algorithm from nonsensical size limits.
Source
Thrown at src/core/output/outputSplit.ts:195
emptyDirPaths,
deps,
}: {
rootDirs: string[];
baseConfig: RepomixConfigMerged;
processedFiles: ProcessedFile[];
allFilePaths: string[];
maxBytesPerPart: number;
gitDiffResult: GitDiffResult | undefined;
gitLogResult: GitLogResult | undefined;
progressCallback: RepomixProgressCallback;
filePathsByRoot?: FilesByRoot[];
emptyDirPaths?: string[];
deps: {
generateOutput: GenerateOutputFn;
};
}): Promise<OutputSplitPart[]> => {
if (!Number.isSafeInteger(maxBytesPerPart) || maxBytesPerPart <= 0) {
throw new RepomixError(`Invalid maxBytesPerPart: ${maxBytesPerPart}`);
}
const groups = buildOutputSplitGroups(processedFiles, allFilePaths);
if (groups.length === 0) {
return [];
}
const parts: OutputSplitPart[] = [];
let currentGroups: OutputSplitGroup[] = [];
let currentContent = '';
let currentBytes = 0;
// Groups are processed via a queue so an oversized group can be replaced in place by its
// finer-grained subdivisions (see below) and re-evaluated without special-casing the loop.
const queue: OutputSplitGroup[] = [...groups];
const finalizeCurrentPart = () => {
parts.push({View on GitHub (pinned to f465ad9093)
Solutions
- Pass a positive integer byte count, e.g. maxBytesPerPart: 50_000_000.
- Parse user input with Number.parseInt and validate before calling.
- Check the upstream calculation for NaN/Infinity (e.g. failed string parsing).
Example fix
// before
const maxBytes = Number.parseInt(argv['max-bytes-per-part']);
await generateSplitOutputParts({ maxBytesPerPart: maxBytes, ... });
// after
const maxBytes = Number.parseInt(argv['max-bytes-per-part'], 10);
if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0) {
throw new Error('maxBytesPerPart must be a positive integer');
}
await generateSplitOutputParts({ maxBytesPerPart: maxBytes, ... }); Defensive patterns
Strategy: validation
Validate before calling
export const isValidMaxBytes = (n: unknown): n is number =>
typeof n === 'number' && Number.isSafeInteger(n) && n > 0;
if (!isValidMaxBytes(maxBytesPerPart)) throw new Error('maxBytesPerPart must be a positive integer'); Type guard
const isPositiveSafeInt = (v: unknown): v is number => typeof v === 'number' && Number.isSafeInteger(v) && v > 0;
Try / catch
try {
await generateSplitOutputParts({ maxBytesPerPart, ... });
} catch (e) {
if (e instanceof RepomixError && e.message.startsWith('Invalid maxBytesPerPart')) {
console.error('Supply a positive integer byte limit, e.g. 50000000');
} else throw e;
} Prevention
- Always parse size options with Number.parseInt(value, 10).
- Validate numeric CLI options at the argument-parsing layer.
- Never compute the limit from unparsed strings like '50MB'.
When it happens
Trigger: Calling generateSplitOutputParts (or the split-output CLI/API path) with maxBytesPerPart computed from bad input: a parse of `--max-bytes-per-part` that yields NaN, an unset option defaulting to 0, or a float value.
Common situations: Passing `--output-split`-style sizing with an empty or malformed value; computing the limit from a byte-size string like "50MB" without parsing; copying example code but omitting the limit constant.
Related errors
- No valid file paths found in stdin input.
- Invalid branch or ref name. Name must not start with '-': ${
- Invalid owner/repo in repo URL
- Invalid remote repository URL or repository shorthand (owner
- Cannot split output: '${group.rootEntry}' exceeds max size o
AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29).
Data as JSON: /api/errors/97d0211644d8df7c.
Report an issue: GitHub.