{"record":{"id":"24450d3dc0818b48","repo":"can1357/oh-my-pi","slug":"invalid-size-value","errorCode":null,"errorMessage":"invalid size: {value}","messagePattern":"invalid size: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/fd.rs","lineNumber":1307,"sourceCode":"\t\t.iter()\n\t\t.map(|value| parse_size_filter(value))\n\t\t.collect()\n}\n\nfn parse_size_filter(value: &str) -> io::Result<SizeFilter> {\n\tlet (ordering, rest) = if let Some(rest) = value.strip_prefix('+') {\n\t\t(SizeOrdering::GreaterOrEqual, rest)\n\t} else if let Some(rest) = value.strip_prefix('-') {\n\t\t(SizeOrdering::LessOrEqual, rest)\n\t} else {\n\t\t(SizeOrdering::Equal, value)\n\t};\n\tlet split = rest\n\t\t.char_indices()\n\t\t.find(|(_, ch)| !ch.is_ascii_digit())\n\t\t.map_or(rest.len(), |(index, _)| index);\n\tif split == 0 {\n\t\treturn Err(io::Error::new(io::ErrorKind::InvalidInput, format!(\"invalid size: {value}\")));\n\t}\n\tlet count = rest[..split]\n\t\t.parse::<u64>()\n\t\t.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err.to_string()))?;\n\tlet unit = rest[split..].to_ascii_lowercase();\n\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,","sourceCodeStart":1289,"sourceCodeEnd":1325,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/fd.rs#L1289-L1325","documentation":"parse_size_filter splits a size spec (optionally prefixed with + or -) into a leading digit run and a trailing unit. When the string contains no leading digits at all — e.g. it starts directly with a unit letter or is empty after the sign — it cannot determine a count and throws this io::Error with ErrorKind::InvalidInput.","triggerScenarios":"Passing a --size value with no numeric portion: '+' or '-' alone, '+mb' (unit before number), 'kb' with no count, or an empty string. Also triggered by non-digit leading characters such as '.5mb' (decimal points are not digits here).","commonSituations":"Users writing find-style sizes like '+1M' but accidentally reversing to '+M1'; copying a size filter with the number stripped by shell quoting/variable expansion (\"+$SIZE\" where SIZE is empty); attempting fractional sizes like '+0.5g' which the parser does not support.","solutions":["Prefix the size with a plain decimal integer, e.g. '+100mb', '-2k', '512b'","Reorder unit-before-number mistakes: '+mb100' → '+100mb'","Check that shell variables interpolating into the value are non-empty","Replace fractional sizes with the equivalent integer in a smaller unit: '+0.5g' → '+500m'"],"exampleFix":"// before\nfd --size '+mb'\n// after\nfd --size '+100mb'","handlingStrategy":"validation","validationCode":"function validateSize(value: string): string | null {\n  const m = /^[+-]?(\\d+)(.*)$/.exec(value);\n  if (!m) return `invalid size: ${value} (need a leading integer, optional +/- prefix, optional unit)`;\n  return null;\n}\n// e.g. validateSize(\"+100mb\") -> null; validateSize(\"+mb\") -> error message","typeGuard":null,"tryCatchPattern":"try {\n  await runFd({ size: value });\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"invalid size: \")) {\n    console.error(`Size must start with digits: ${err.message}. Example: +100m`);\n  } else throw err;\n}","preventionTips":["Assert shell variables interpolated into size flags are non-empty and numeric","Use a regex ^[+-]?\\d+ as a gate before invoking","Remember fractional sizes are unsupported — convert 0.5g to 500m","Keep the sign prefix (+/-) attached to the number, not the unit"],"tags":["cli","argument-validation","size-parsing","invalid-input"],"backgroundTag":"invalid-size-format","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}