{"record":{"id":"4120a43cc34303cf","repo":"yamadashy/repomix","slug":"invalid-size-input-resulting-byte-value-is","errorCode":null,"errorMessage":"Invalid size: '${input}'. Resulting byte value is too large.","messagePattern":"Invalid size: '(.+?)'\\. Resulting byte value is too large\\.","errorType":"validation","errorClass":"RepomixError","httpStatus":null,"severity":"error","filePath":"src/shared/sizeParse.ts","lineNumber":23,"sourceCode":"export const parseHumanSizeToBytes = (input: string): number => {\n  const match = SIZE_RE.exec(input);\n  if (!match) {\n    throw new RepomixError(\n      `Invalid size: '${input}'. Expected format like '500kb', '2mb', or '2.5mb' (case-insensitive).`,\n    );\n  }\n\n  const amount = Number(match[1]);\n  if (!Number.isFinite(amount) || amount <= 0) {\n    throw new RepomixError(`Invalid size amount: '${match[1]}'. Must be a positive number.`);\n  }\n\n  const unit = match[2].toLowerCase();\n  const multiplier = unit === 'kb' ? 1024 : 1024 * 1024;\n  const bytes = Math.floor(amount * multiplier);\n\n  if (!Number.isSafeInteger(bytes)) {\n    throw new RepomixError(`Invalid size: '${input}'. Resulting byte value is too large.`);\n  }\n\n  return bytes;\n};\n","sourceCodeStart":5,"sourceCodeEnd":28,"githubUrl":"https://github.com/yamadashy/repomix/blob/f465ad909315a22120636baf03fa5e28701a50cb/src/shared/sizeParse.ts#L5-L28","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use a realistic size within safe-integer bytes (under ~8 exabytes, practically any sane size like '1024mb')","Omit the size option if you meant 'no limit' instead of using a huge number","Check generated config for runaway numeric values"],"exampleFix":"// before\n{ \"output\": { \"truncateSize\": \"99999999999999mb\" } }\n// after\n{ \"output\": { \"truncateSize\": \"1024mb\" } }","handlingStrategy":"validation","validationCode":"const m = /^\\s*(\\d+(?:\\.\\d+)?)\\s*(kb|mb)\\s*$/i.exec(raw);\nif (m) {\n  const bytes = Math.floor(Number(m[1]) * (m[2].toLowerCase() === 'kb' ? 1024 : 1048576));\n  if (!Number.isSafeInteger(bytes)) throw new Error(`'${raw}' is too large`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const bytes = parseHumanSizeToBytes(raw);\n} catch (e) {\n  if (String(e.message).includes('too large')) {\n    // clamp to a sane maximum instead of the huge value\n  } else throw e;\n}","preventionTips":["Clamp programmatically generated sizes to a sane max (e.g. 1gb)","Use option omission for 'unlimited' rather than huge sentinel values","Check config for accidental extra digits"],"tags":["config","validation","size-parsing"],"backgroundTag":"invalid-size-format","analyzedSha":"f465ad909315a22120636baf03fa5e28701a50cb","analyzedAt":"2026-08-29T01:27:42.024Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}