{"record":{"id":"0306286966815afd","repo":"sharkdp/fd","slug":"is-not-a-valid-size-constraint-see-fd-hel","errorCode":null,"errorMessage":"'{}' is not a valid size constraint. See 'fd --help'.","messagePattern":"'(.+?)' is not a valid size constraint\\. See 'fd --help'\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/filter/size.rs","lineNumber":30,"sourceCode":"    Equals(u64),\n}\n\n// SI prefixes (powers of 10)\nconst KILO: u64 = 1000;\nconst MEGA: u64 = KILO * 1000;\nconst GIGA: u64 = MEGA * 1000;\nconst TERA: u64 = GIGA * 1000;\n\n// Binary prefixes (powers of 2)\nconst KIBI: u64 = 1024;\nconst MEBI: u64 = KIBI * 1024;\nconst GIBI: u64 = MEBI * 1024;\nconst TEBI: u64 = GIBI * 1024;\n\nimpl SizeFilter {\n    pub fn from_string(s: &str) -> anyhow::Result<Self> {\n        SizeFilter::parse_opt(s)\n            .ok_or_else(|| anyhow!(\"'{}' is not a valid size constraint. See 'fd --help'.\", s))\n    }\n\n    fn parse_opt(s: &str) -> Option<Self> {\n        let pattern =\n            SIZE_CAPTURES.get_or_init(|| Regex::new(r\"(?i)^([+-]?)(\\d+)(b|[kmgt]i?b?)$\").unwrap());\n        if !pattern.is_match(s) {\n            return None;\n        }\n\n        let captures = pattern.captures(s)?;\n        let limit_kind = captures.get(1).map_or(\"+\", |m| m.as_str());\n        let quantity = captures\n            .get(2)\n            .and_then(|v| v.as_str().parse::<u64>().ok())?;\n\n        let multiplier = match &captures.get(3).map_or(\"b\", |m| m.as_str()).to_lowercase()[..] {\n            v if v.starts_with(\"ki\") => KIBI,\n            v if v.starts_with('k') => KILO,","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/sharkdp/fd/blob/ee20f426ddf338ac7ead5c5f00ea49258005caaf/src/filter/size.rs#L12-L48","documentation":"SizeFilter::from_string (filter/size.rs:30) requires the --size value to match the regex (?i)^([+-]?)(\\d+)(b|[kmgt]i?b?)$. The optional sign selects Min (+) or Max (-); the unit must be one of b/k/m/g/t in SI or ki/mi/gi/ti binary forms. Anything not matching (e.g. bare number, bad unit, negative number without sign usage) yields this error.","triggerScenarios":"Passing `fd --size 5` (no unit), `fd --size 5x`, `fd --size abc`, `fd --size 1.5k` (decimals not supported), or `fd --size kb` (missing magnitude). The regex requires an integer magnitude and a recognized unit.","commonSituations":"Forgetting the unit; using a decimal point; typing unsupported units like 'pb'/bytes-only with no suffix; confusing fd's syntax with du/find -size syntax.","solutions":["Add a recognized unit: `fd --size 5k`, `fd --size +10m`, `fd --size -1g`, `fd --size 100b`.","For 'larger than' prefix '+', for 'smaller than' prefix '-', for exact omit the sign.","Use binary units if needed: `fd --size 1mi`, `fd --size 2gi`."],"exampleFix":"# before\nfd --size 5\n\n# after\nfd --size 5k      # exactly 5 KB\nfd --size +10m   # at least 10 MB\nfd --size -1g    # less than 1 GB","handlingStrategy":"validation","validationCode":"validate_size() {\n  # pattern: optional +/-, integer, unit b|k|ki|m|mi|g|gi|t|ti(+b)\n  printf '%s' \"$1\" | grep -Eq '^[+-]?[0-9]+(b|k|ki|m|mi|g|gi|t|ti)b?$' && fd --size \"$1\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include a unit; bare numbers are rejected.","Use '+' for minimum and '-' for maximum; no sign means exact.","Avoid decimal points; round to an integer magnitude."],"tags":["size-filter","parsing","cli"],"backgroundTag":null,"analyzedSha":"ee20f426ddf338ac7ead5c5f00ea49258005caaf","analyzedAt":"2026-08-09T08:21:40.573Z","contentChangedAt":"2026-08-09T08:21:40.573Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}