{"record":{"id":"6b80b99367f0b01a","repo":"actix/actix-web","slug":"required-field-is-missing-0-6b80b9","errorCode":null,"errorMessage":"Required field is missing \"{_0}\"","messagePattern":"Required field is missing \"(.+?)\"","errorType":"validation","errorClass":"Error","httpStatus":400,"severity":"warning","filePath":"actix-multipart/src/error.rs","lineNumber":91,"sourceCode":"    #[display(\"Stream is not consumed\")]\n    NotConsumed,\n\n    /// 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\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)]","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/actix/actix-web/blob/c215607f4b6e9ba9accff4a949a33c98f218db20/actix-multipart/src/error.rs#L73-L109","documentation":"This is `actix_multipart::form::Error::MissingField(String)` raised by actix-multipart's typed form deserialization (`MultipartForm`). It means a required (non-Option) struct field did not receive a corresponding multipart part in the submitted body. The library cannot construct the target struct, so it fails the request with this validation error.","triggerScenarios":"A `#[derive(MultipartForm)]` struct has a non-Option field, and `MultipartForm::from_request` finishes consuming parts without ever seeing a part with that field's name.","commonSituations":"Client form omitted an input the server requires, the input's `name` attribute does not match the Rust field name, curl/tests built manually without all parts, or the client sent JSON instead of multipart/form-data.","solutions":["Make the field optional in the struct (`Option<T>`) if the client is allowed to omit it.","Fix the client form so every required field's `name` matches the Rust struct field (or `#[multipart(rename = \"...\")]`).","Verify the request uses `Content-Type: multipart/form-data` with a proper boundary and that the part name matches exactly (case-sensitive).","Test with curl `-F name=value` to reproduce and confirm which part the server expects."],"exampleFix":"// before\nstruct Form { title: String } // client sometimes omits 'title'\n// after\nstruct Form { title: Option<String> } // or send the part: curl -F title=hello ...","handlingStrategy":"validation","validationCode":"// client-side, before submit\nconst required = [\"title\", \"file\"];\nconst missing = required.filter((n) => !formData.has(n));\nif (missing.length) throw new Error(`missing multipart fields: ${missing.join(\", \")}`);","typeGuard":"// server-side: mark truly-optional fields as Option<T>\nfn is_optional<T>(_: &Option<T>) -> bool { true }","tryCatchPattern":"match form_result {\n    Err(e) if e.to_string().contains(\"Required field is missing\") =>\n        ErrHttpResponse::build(StatusCode::BAD_REQUEST).body(\"missing required form field\"),\n    other => other,\n}","preventionTips":["Match client input `name` attributes exactly (case-sensitive) to Rust struct field names or #[multipart(rename)] values","Verify the request is multipart/form-data with a valid boundary, not urlencoded or JSON","Use HTML `required` attributes plus client-side checks for required inputs","Keep a contract test that posts a minimal valid form for every MultipartForm struct"],"tags":["multipart","form-validation","actix-web","missing-field"],"backgroundTag":"missing-required-argument","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"}