{"id":"fa3db336645960ac","repo":"actix/actix-web","slug":"unknown-field-0","errorCode":null,"errorMessage":"Unknown field: {_0}","messagePattern":"Unknown field: (.+?)","errorType":"exception","errorClass":"actix_multipart::Error","httpStatus":400,"severity":"error","filePath":"actix-multipart/src/error.rs","lineNumber":92,"sourceCode":"    /// Form field handler raised error.\n    #[display(\"An error occurred processing field: {name}\")]\n    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::*;","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/actix/actix-web/blob/937960ca67f20e14ffe2a075bf6d4593502be12c/actix-multipart/src/error.rs#L74-L110","documentation":"MultipartError::UnknownField(String) (multipart/error.rs:92-94) is emitted by the derived MultipartCollect implementation (actix-multipart-derive/src/lib.rs:135) when an incoming multipart part's name does not match any declared field of the struct and the struct opts in to denying unknown fields (deny_unknown_fields). It maps to HTTP 400 BadRequest. Without deny_unknown_fields, unknown parts are silently ignored.","triggerScenarios":"A multipart/form-data request contains a part whose Content-Disposition name is not a field of the target struct, and the struct is annotated with #[multipart(deny_unknown_fields)]. The derive macro's handle_field falls through to the UnknownField branch.","commonSituations":"Client sends an extra field the backend does not expect, a newer frontend shipping fields the older backend lacks, or a typo in the field name on either side.","solutions":["Remove the unexpected field from the client request, or fix the name typo.","If the extra field is intentional, add it to the struct or remove deny_unknown_fields.","Log the offending field name (it is included in the error) to pinpoint the mismatch."],"exampleFix":"// before: unknown field rejected\n#[derive(MultipartForm)]\n#[multipart(deny_unknown_fields)]\nstruct Form { name: String }   // client also sends 'age'\n\n// after: accept and capture it\n#[derive(MultipartForm)]\n#[multipart(deny_unknown_fields)]\nstruct Form { name: String, age: Option<String> }","handlingStrategy":"validation","validationCode":"// Client-side: filter the FormData to known field names before sending.\nconst allowed = new Set(['name', 'age']);\nfor (const key of [...fd.keys()]) {\n  if (!allowed.has(key)) fd.delete(key);\n}","typeGuard":null,"tryCatchPattern":"// 400 UnknownField is returned by the extractor; customise via error handler.\n// Downcast the ResponseError to MultipartError::UnknownField(name)\n// to show the offending field name to the caller.","preventionTips":["Only enable #[multipart(deny_unknown_fields)] when strictness is required.","Keep frontend and backend field sets in sync (shared schema/types).","Log the unknown field name to catch schema drift early."],"tags":["multipart","form","actix-multipart","validation"],"analyzedSha":"937960ca67f20e14ffe2a075bf6d4593502be12c","analyzedAt":"2026-08-06T01:15:46.978Z","schemaVersion":2}