{"record":{"id":"bd5021880ccad2b2","repo":"can1357/oh-my-pi","slug":"size-is-too-large-value","errorCode":null,"errorMessage":"size is too large: {value}","messagePattern":"size is too large: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/fd.rs","lineNumber":1331,"sourceCode":"\tlet multiplier = match unit.as_str() {\n\t\t\"\" | \"b\" => 1,\n\t\t\"k\" => 1_000,\n\t\t\"m\" => 1_000_000,\n\t\t\"g\" => 1_000_000_000,\n\t\t\"t\" => 1_000_000_000_000,\n\t\t\"ki\" => 1_024,\n\t\t\"mi\" => 1_048_576,\n\t\t\"gi\" => 1_073_741_824,\n\t\t\"ti\" => 1_099_511_627_776,\n\t\t_ => {\n\t\t\treturn Err(io::Error::new(\n\t\t\t\tio::ErrorKind::InvalidInput,\n\t\t\t\tformat!(\"invalid size unit: {unit}\"),\n\t\t\t));\n\t\t},\n\t};\n\tlet bytes = count.checked_mul(multiplier).ok_or_else(|| {\n\t\tio::Error::new(io::ErrorKind::InvalidInput, format!(\"size is too large: {value}\"))\n\t})?;\n\tOk(SizeFilter { ordering, bytes })\n}\n\nfn parse_time_filter(value: &str) -> io::Result<SystemTime> {\n\tif let Some(timestamp) = value.strip_prefix('@') {\n\t\tlet seconds = timestamp\n\t\t\t.parse::<u64>()\n\t\t\t.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err.to_string()))?;\n\t\treturn Ok(UNIX_EPOCH + Duration::from_secs(seconds));\n\t}\n\tif let Some(duration) = parse_duration(value)? {\n\t\treturn SystemTime::now().checked_sub(duration).ok_or_else(|| {\n\t\t\tio::Error::new(io::ErrorKind::InvalidInput, format!(\"duration is too large: {value}\"))\n\t\t});\n\t}\n\tparse_utc_datetime(value)\n}","sourceCodeStart":1313,"sourceCodeEnd":1349,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/fd.rs#L1313-L1349","documentation":"After resolving the unit multiplier, parse_size_filter computes count * multiplier with u64::checked_mul. If the product overflows u64 (e.g. a large count with the t = 1,000,000,000,000 multiplier), the computation is refused and this io::Error with ErrorKind::InvalidInput naming the original value is thrown. This prevents silent wraparound in size comparisons.","triggerScenarios":"Passing a --size whose digit count times its unit exceeds u64::MAX: e.g. '+18446744073710t' (≈1.8e22 bytes), '99999999999ti' (≈1.1e14 × ... overflow), or even a 20-digit count with any multiplier above 1. The digit-run parse (error 32) succeeds here; the overflow happens at multiplication.","commonSituations":"Users intending 'infinite' or 'no upper bound' sizes by typing an enormous number instead of omitting the + filter; generated scripts computing byte thresholds in a float-typed variable then formatting with full precision; confusion of petabyte-scale values with byte counts.","solutions":["Lower the count: any practical size fits — '1000t' (10^15 bytes) is fine, but check count*multiplier ≤ 18446744073709551615","Express the threshold in a larger unit rather than a huge count in a small unit","To match 'all files above X', pick a realistic ceiling (e.g. '+10t') instead of a sentinel huge value","Pre-check in code: parse the count as u64 and compare against u64::MAX / multiplier before calling"],"exampleFix":"// before\nfd --size '+99999999999999999999'   // overflows with multiplier\n// after\nfd --size '+99t'  // 99 terabytes, well within u64","handlingStrategy":"validation","validationCode":"const MULTIPLIERS: Record<string, number> = { \"\":1, b:1, k:1_000, m:1_000_000, g:1_000_000_000, t:1_000_000_000_000, ki:1_024, mi:1_048_576, gi:1_073_741_824, ti:1_099_511_627_776 };\nfunction validateSizeFits(value: string): string | null {\n  const m = /^([+-]?)(\\d+)(.*)$/.exec(value);\n  if (!m) return null;\n  const count = BigInt(m[2]); const mult = BigInt(MULTIPLIERS[m[3].toLowerCase()] ?? 1);\n  return count * mult > 18446744073709551615n ? `size is too large: ${value}` : null;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runFd({ size: value });\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"size is too large: \")) {\n    console.error(`${err.message} — count*unit exceeds u64; pick a smaller count or bigger unit.`);\n  } else throw err;\n}","preventionTips":["Compute count * multiplier with BigInt or checked arithmetic in generating scripts","Never use sentinel 'infinity' sizes — omit the + filter or pick a realistic ceiling","Sanitize float-formatted sizes (avoid 1e22 spelled out as a 23-digit integer)","Keep sizes under 18.4 EB (u64::MAX bytes); anything larger is unsupported by the u64 byte model"],"tags":["cli","size-parsing","integer-overflow","invalid-input"],"backgroundTag":"number-out-of-range","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}