{"record":{"id":"1efa3309e405a505","repo":"actix/actix-web","slug":"unknown-field-0-1efa33","errorCode":null,"errorMessage":"Unknown field \"{_0}\"","messagePattern":"Unknown field \"(.+?)\"","errorType":"validation","errorClass":"Error","httpStatus":400,"severity":"warning","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\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 err_report::Report;\n\n    use super::*;\n","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/actix/actix-web/blob/c215607f4b6e9ba9accff4a949a33c98f218db20/actix-multipart/src/error.rs#L78-L114","documentation":"This is `actix_multipart::form::Error::UnknownField(String)` raised by actix-multipart's typed form deserialization when the struct has opted in to denying unknown fields. It means the multipart body contained a part whose field name does not correspond to any field of the target `MultipartForm` struct. The library rejects the request instead of ignoring the extra part.","triggerScenarios":"During `MultipartForm::from_request`, a part's name matches no field of the derive(MultipartForm) struct (with deny-unknown-fields behavior active), so parsing fails with the offending name.","commonSituations":"Client form updated with new inputs while the server struct was not, typos in the input `name` attribute, generic client tooling sending extra metadata fields, or version skew between an older cached frontend and a newer backend.","solutions":["Add a matching field to the MultipartForm struct (or fix the rename attribute) so the extra part is recognized.","Fix the client form to remove or rename the extra input so it matches the server schema.","If extra parts should be tolerated, configure the form to ignore unknown fields instead of denying them.","Use the field name in the error to diff the client's multipart payload against the server struct definition."],"exampleFix":"// before: client sends 'comment', struct lacks it\nstruct Form { file: File }\n// after\nstruct Form { file: File, comment: Option<String> }","handlingStrategy":"validation","validationCode":"// client-side: keep payload keys in sync with the server schema\nconst ALLOWED = new Set([\"file\", \"comment\"]);\nconst extra = [...formData.keys()].filter((n) => !ALLOWED.has(n));\nif (extra.length) throw new Error(`unknown multipart fields: ${extra.join(\", \")}`);","typeGuard":"// server-side: any field you wish to ignore must exist in the struct; there is no wildcard\nderive(MultipartForm)\nstruct Form { file: File, #[multipart(rename = \"comment\")] comment: Option<String> }","tryCatchPattern":"match form_result {\n    Err(e) if e.to_string().contains(\"Unknown field\") =>\n        ErrHttpResponse::build(StatusCode::BAD_REQUEST).body(\"form contains unrecognized field\"),\n    other => other,\n}","preventionTips":["Version-check the client form against the server struct schema before deploying either side","Remove stale hidden inputs from templates when the backend schema changes","Add a server test that posts the exact field set the production client sends","When adding a client-side field, update the MultipartForm struct in the same PR"],"tags":["multipart","form-validation","actix-web","unknown-field"],"backgroundTag":"schema-validation-failed","analyzedSha":"c215607f4b6e9ba9accff4a949a33c98f218db20","analyzedAt":"2026-09-09T15:57:34.010Z","contentChangedAt":"2026-09-09T15:57:34.010Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}