{"record":{"id":"5f85af3e98562765","repo":"seanmonstar/warp","slug":"unsupported-media-type","errorCode":null,"errorMessage":"unsupported_media_type","messagePattern":"unsupported_media_type","errorType":"http","errorClass":"UnsupportedMediaType","httpStatus":415,"severity":"error","filePath":"src/filters/body.rs","lineNumber":279,"sourceCode":"    filter_fn(move |route| {\n        let (type_, subtype) = D::MIME;\n        if let Some(value) = route.headers().get(CONTENT_TYPE) {\n            tracing::trace!(\"is_content_type {}/{}? {:?}\", type_, subtype, value);\n            let ct = value\n                .to_str()\n                .ok()\n                .and_then(|s| s.parse::<mime::Mime>().ok());\n            if let Some(ct) = ct {\n                if ct.type_() == type_ && ct.subtype() == subtype {\n                    future::ok(())\n                } else {\n                    tracing::debug!(\n                        \"content-type {:?} doesn't match {}/{}\",\n                        value,\n                        type_,\n                        subtype\n                    );\n                    future::err(reject::unsupported_media_type())\n                }\n            } else {\n                tracing::debug!(\"content-type {:?} couldn't be parsed\", value);\n                future::err(reject::unsupported_media_type())\n            }\n        } else if D::WITH_NO_CONTENT_TYPE {\n            // Optimistically assume its correct!\n            tracing::trace!(\"no content-type header, assuming {}/{}\", type_, subtype);\n            future::ok(())\n        } else {\n            tracing::debug!(\"no content-type found\");\n            future::err(reject::unsupported_media_type())\n        }\n    })\n}\n\n// ===== Rejections =====\n","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/seanmonstar/warp/blob/ff34d7213ed55ec342304aa7ff6ac4b351da9e66/src/filters/body.rs#L261-L297","documentation":"warp::body's is_content_type filter rejects the request with an unsupported_media_type (415) rejection when the Content-Type header is present but its MIME type does not match the MIME type expected by the body decoder (D::MIME, e.g. application/json for warp::body::json()). It is a validation helper guarding deserializers: only requests whose parsed Content-Type equals the expected type_/subtype pass.","triggerScenarios":"Thrown at src/filters/body.rs:279 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the client's Content-Type header to match the expected decoder, e.g. application/json for warp::body::json() or application/x-www-form-urlencoded for form()","Handle the rejection with .recover() and map reject::unsupported_media_type() to a 415 response listing accepted media types","Use the matching body filter for the actual payload format (json(), form(), text(), bytes())","Check for missing charset/parameters issues: the MIME parse only compares type and subtype, so ensure the header itself is a parseable MIME string"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ff34d7213ed55ec342304aa7ff6ac4b351da9e66","analyzedAt":"2026-09-09T16:57:46.316Z","contentChangedAt":"2026-09-09T16:57:46.316Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}