{"record":{"id":"cb5a95496b767b90","repo":"actix/actix-web","slug":"multiple-fields-named","errorCode":null,"errorMessage":"Multiple fields named: `{}`","messagePattern":"Multiple fields named: `(.+?)`","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"actix-multipart-derive/src/lib.rs","lineNumber":125,"sourceCode":"\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,\n        Err(err) => return err,\n    };\n\n    // Check that field names are unique\n    let mut set = HashSet::new();\n    for field in &parsed {\n        if !set.insert(field.serialization_name.clone()) {\n            return compile_err(syn::Error::new(\n                field.rust_name.span(),\n                format!(\"Multiple fields named: `{}`\", field.serialization_name),\n            ));\n        }\n    }\n\n    // Return value when a field name is not supported by the form\n    let unknown_field_result = if attrs.deny_unknown_fields {\n        quote!(::std::result::Result::Err(\n            ::actix_multipart::MultipartError::UnknownField(field.name().unwrap().to_string())\n        ))\n    } else {\n        quote!(::actix_multipart::form::discard_field(field, limits).await)\n    };\n\n    // Value for duplicate action\n    let duplicate_field = match attrs.duplicate_field {\n        DuplicateField::Ignore => quote!(::actix_multipart::form::DuplicateField::Ignore),","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/actix/actix-web/blob/4d435abc281842f3cbee165b6cde739e001d3a25/actix-multipart-derive/src/lib.rs#L107-L143","documentation":"This compile-time error fires when two or more fields in a `#[derive(MultipartForm)]` struct resolve to the same serialization name (after considering `#[multipart(rename = \"...\")]`). The macro inserts each serialization name into a `HashSet` at line 122-130 and rejects duplicates because it cannot disambiguate which Rust field should receive a given multipart part.","triggerScenarios":"Two fields with the same name, or two fields where one is renamed to match another's name (or default name). For example, `struct Form { a: Bytes, #[multipart(rename = \"a\")] b: Bytes }` will collide because both serialize as `\"a\"`.","commonSituations":"Using `rename` to map multiple fields to the same multipart field name by mistake, or copy-pasting field names during refactoring.","solutions":["Rename one of the conflicting fields so each has a unique serialization name","Remove the `#[multipart(rename = ...)]` that causes the collision","Merge the two fields into a single field if they truly represent the same multipart part"],"exampleFix":"// before\n#[derive(MultipartForm)]\nstruct Form {\n    avatar: Bytes,\n    #[multipart(rename = \"avatar\")]\n    photo: Bytes,\n}\n\n// after\n#[derive(MultipartForm)]\nstruct Form {\n    avatar: Bytes,\n    banner: Bytes,\n}","handlingStrategy":"validation","validationCode":"// Before compiling, check that all field names (including renames) are unique.\n// Each field's serialization name = #[multipart(rename = \"...\")] value or the Rust field name.\n// Ensure no two fields produce the same serialization name.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Audit all #[multipart(rename = \"...\")] attributes to ensure no two fields map to the same name","Keep a single naming convention: either use Rust field names directly or rename consistently","Run cargo check after adding or renaming fields"],"tags":["rust","actix-web","multipart","derive-macro","compile-time"],"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"}