{"record":{"id":"fa3db336645960ac","repo":"actix/actix-web","slug":"unknown-field-0","errorCode":null,"errorMessage":"Unknown field: {_0}","messagePattern":"Unknown field: (.+?)","errorType":"http","errorClass":"actix_multipart::Error","httpStatus":400,"severity":"error","filePath":"actix-multipart/src/error.rs","lineNumber":96,"sourceCode":"    Field {\n        name: String,\n        source: actix_web::Error,\n    },\n\n    /// Duplicate field found (for structure that opted-in to denying duplicate fields).\n    #[display(\"Duplicate field found: {_0}\")]\n    #[from(ignore)]\n    DuplicateField(#[error(not(source))] String),\n\n    /// Required field is missing.\n    #[display(\"Required field is missing: {_0}\")]\n    #[from(ignore)]\n    MissingField(#[error(not(source))] String),\n\n    /// Unknown field (for structure that opted-in to denying unknown fields).\n    #[display(\"Unknown field: {_0}\")]\n    #[from(ignore)]\n    UnknownField(#[error(not(source))] String),\n}\n\n/// Return `BadRequest` for `MultipartError`.\nimpl ResponseError for Error {\n    fn status_code(&self) -> StatusCode {\n        match &self {\n            Error::Field { source, .. } => source.as_response_error().status_code(),\n            Error::ContentTypeIncompatible => StatusCode::UNSUPPORTED_MEDIA_TYPE,\n            _ => StatusCode::BAD_REQUEST,\n        }\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/actix/actix-web/blob/7ae209e4a4f3c8df61cacb9c2d3b8ef28ebda0d6/actix-multipart/src/error.rs#L78-L114","documentation":"Error::UnknownField(String) is raised by code generated by the MultipartForm derive macro (multipart-derive/src/lib.rs:135) when a struct is marked #[multipart(deny_unknown_fields)] and an incoming part's name does not match any declared field. Without deny_unknown_fields unknown parts are silently discarded (lib.rs:138). The error surfaces as a 400 Bad Request.","triggerScenarios":"A handler struct annotated #[multipart(deny_unknown_fields)] receives a part whose name is not one of its fields. Test test_deny_unknown at form/mod.rs:744 sends an \"unknown\" part and expects 400.","commonSituations":"Client sending extra/legacy fields; field renamed server-side but client still sends the old name; a honeypot anti-spam field; stricter validation turned on during a refactor.","solutions":["Remove #[multipart(deny_unknown_fields)] if extra fields should be ignored (the default).","Align client and server field names, including any #[multipart(rename = \"...\")] attributes.","Keep deny_unknown_fields and fix the client to send only known fields."],"exampleFix":"// before\n#[derive(MultipartForm)]\n#[multipart(deny_unknown_fields)]\nstruct Form { name: Text<String> } // client sends \"legacy\" => 400\n\n// after (tolerate extras)\n#[derive(MultipartForm)]\nstruct Form { name: Text<String> } // extras discarded","handlingStrategy":"validation","validationCode":"// Only opt into strictness when you control the client\n#[derive(MultipartForm)]\nstruct Form { name: Text<String> } // unknown fields discarded by default\n// add #[multipart(deny_unknown_fields)] only if extras are truly an error","typeGuard":null,"tryCatchPattern":"match form_result {\n    Err(e) if is_unknown_field(&e) => {\n        return HttpResponse::BadRequest().body(\"unexpected form field\");\n    }\n    _ => { /* ... */ }\n}","preventionTips":["Default behavior already ignores unknown fields; don't add deny_unknown_fields unless needed.","Keep client/server field names aligned.","Document expected fields for API consumers."],"tags":["multipart","form-data","actix-multipart","validation"],"backgroundTag":null,"analyzedSha":"7ae209e4a4f3c8df61cacb9c2d3b8ef28ebda0d6","analyzedAt":"2026-08-09T01:01:40.926Z","contentChangedAt":"2026-08-09T01:01:40.926Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}