{"record":{"id":"a5857aec83b3542c","repo":"actix/actix-web","slug":"could-not-parse-size-limit","errorCode":null,"errorMessage":"Could not parse size limit `{}`: {}","messagePattern":"Could not parse size limit `(.+?)`: (.+?)","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"actix-multipart-derive/src/lib.rs","lineNumber":99,"sourceCode":"    };\n\n    let attrs = match MultipartFormAttrs::from_derive_input(&input) {\n        Ok(attrs) => attrs,\n        Err(err) => return err.write_errors().into(),\n    };\n\n    // Parse the field attributes\n    let parsed = match fields\n        .named\n        .iter()\n        .map(|field| {\n            let rust_name = field.ident.as_ref().unwrap();\n            let attrs = FieldAttrs::from_field(field).map_err(|err| err.write_errors())?;\n            let serialization_name = attrs.rename.unwrap_or_else(|| rust_name.to_string());\n\n            let limit = match attrs.limit.map(|limit| match limit.parse::<ByteSize>() {\n                Ok(ByteSize(size)) => Ok(usize::try_from(size).unwrap()),\n                Err(err) => Err(syn::Error::new(\n                    field.ident.as_ref().unwrap().span(),\n                    format!(\"Could not parse size limit `{}`: {}\", limit, err),\n                )),\n            }) {\n                Some(Err(err)) => return Err(compile_err(err)),\n                limit => limit.map(Result::unwrap),\n            };\n\n            Ok(ParsedField {\n                serialization_name,\n                rust_name,\n                limit,\n                ty: &field.ty,\n            })\n        })\n        .collect::<Result<Vec<_>, TokenStream>>()\n    {\n        Ok(attrs) => attrs,","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/actix/actix-web/blob/4d435abc281842f3cbee165b6cde739e001d3a25/actix-multipart-derive/src/lib.rs#L81-L117","documentation":"This compile-time error fires when the `#[multipart(limit = \"...\")]` attribute on a field contains a string that cannot be parsed as a human-readable byte size by the `bytesize` crate. The macro attempts `limit.parse::<ByteSize>()` at line 97 and surfaces the underlying parse error with the offending value.","triggerScenarios":"Writing a field attribute like `#[multipart(limit = \"10\")]` (bare number without unit suffix is not accepted by ByteSize in this version), `#[multipart(limit = \"abc\")]`, or using an unrecognized unit like `#[multipart(limit = \"5xb\")]`.","commonSituations":"Developers who assume raw numbers or non-standard abbreviations are accepted. The `bytesize` crate expects formats like `\"5MiB\"`, `\"10MB\"`, `\"1GiB\"` with an explicit unit.","solutions":["Use a valid byte-size string with a unit, e.g. `#[multipart(limit = \"10MiB\")]`","Check the bytesize crate documentation for supported unit suffixes: B, KB, KiB, MB, MiB, GB, GiB, TB, TiB","Ensure the value is a string literal, not a raw number or expression"],"exampleFix":"// before\n#[derive(MultipartForm)]\nstruct Form {\n    #[multipart(limit = \"5\")]\n    file: Bytes,\n}\n\n// after\n#[derive(MultipartForm)]\nstruct Form {\n    #[multipart(limit = \"5MiB\")]\n    file: Bytes,\n}","handlingStrategy":"validation","validationCode":"// Validate the limit string format before using it in the attribute.\n// Accepted units (bytesize crate): B, KB, KiB, MB, MiB, GB, GiB, TB, TiB\n// Example valid strings: \"5MiB\", \"10MB\", \"1GiB\", \"256KiB\"\n// Note: bare numbers like \"5\" are NOT valid; always include a unit.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include a unit suffix in #[multipart(limit = \"...\")] attributes (e.g. \"10MiB\")","Refer to the bytesize crate documentation for the exact supported formats","Run cargo check immediately after setting a limit to catch parse errors at compile time"],"tags":["rust","actix-web","multipart","derive-macro","compile-time","configuration"],"backgroundTag":null,"analyzedSha":"4d435abc281842f3cbee165b6cde739e001d3a25","analyzedAt":"2026-08-09T01:01:40.926Z","contentChangedAt":"2026-08-09T01:01:40.926Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}