{"record":{"id":"c2461dc2a55b2f8a","repo":"rwf2/Rocket","slug":"unexpectedeof-c2461d","errorCode":"UnexpectedEof","errorMessage":"data limit exceeded","messagePattern":"data limit exceeded","errorType":"http","errorClass":"rocket::serde::msgpack::Error","httpStatus":413,"severity":"error","filePath":"core/lib/src/serde/msgpack.rs","lineNumber":185,"sourceCode":"    /// ```\n    #[inline(always)]\n    pub fn into_inner(self) -> T {\n        self.0\n    }\n}\n\nimpl<'r, T: Deserialize<'r>> MsgPack<T> {\n    fn from_bytes(buf: &'r [u8]) -> Result<Self, Error> {\n        rmp_serde::from_slice(buf).map(MsgPack)\n    }\n\n    async fn from_data(req: &'r Request<'_>, data: Data<'r>) -> Result<Self, Error> {\n        let limit = req.limits().get(\"msgpack\").unwrap_or(Limits::MESSAGE_PACK);\n        let bytes = match data.open(limit).into_bytes().await {\n            Ok(buf) if buf.is_complete() => buf.into_inner(),\n            Ok(_) => {\n                let eof = io::ErrorKind::UnexpectedEof;\n                return Err(Error::InvalidDataRead(io::Error::new(eof, \"data limit exceeded\")));\n            },\n            Err(e) => return Err(Error::InvalidDataRead(e)),\n        };\n\n        Self::from_bytes(local_cache!(req, bytes))\n    }\n}\n\n#[crate::async_trait]\nimpl<'r, T: Deserialize<'r>> FromData<'r> for MsgPack<T> {\n    type Error = Error;\n\n    async fn from_data(req: &'r Request<'_>, data: Data<'r>) -> Outcome<'r, Self> {\n        match Self::from_data(req, data).await {\n            Ok(value) => Outcome::Success(value),\n            Err(Error::InvalidDataRead(e)) if e.kind() == io::ErrorKind::UnexpectedEof => {\n                Outcome::Error((Status::PayloadTooLarge, Error::InvalidDataRead(e)))\n            },","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/rwf2/Rocket/blob/3a54d079aef060a8f732bd04ea54b0581a604087/core/lib/src/serde/msgpack.rs#L167-L203","documentation":"Runtime error from the MsgPack<T> FromData guard (core/lib/src/serde/msgpack.rs): the body is opened with the 'msgpack' limit (Limits::MESSAGE_PACK, default 1 MiB); if reading stops at that limit with more data remaining (into_bytes returns an incomplete Capped), the guard errors with io::ErrorKind::UnexpectedEof 'data limit exceeded' wrapped in Error::InvalidDataRead, failing the MsgPack guard (typically 413/400 depending on catcher). Same policy as the JSON guard, applied to application/msgpack bodies.","triggerScenarios":"POSTing an application/msgpack (or msgpack content-type) body larger than limits.msgpack (default 1 MiB) to a route with a MsgPack<T> guard.","commonSituations":"Binary-heavy APIs (embedded telemetry, sensor batches, serialized ML features) packing large blobs into one msgpack document; payload growth after launch; msgpack chosen specifically for large binary data without raising the limit.","solutions":["Raise the limit: Rocket.toml [default.limits] msgpack = \"10 MiB\"","Split large binary payloads into multiple requests or use Data<'_>/TempFile streaming instead of MsgPack<T>","Add a catcher for the resulting status so clients get a clear 'payload too large' message","Verify with a sized test payload (head -c 2M /dev/urandom as msgpack body)"],"exampleFix":"# before\n# Rocket.toml (msgpack defaults to 1 MiB)\n#[post(\"/ingest\", data = \"<batch>\")]\nfn ingest(batch: MsgPack<Batch>) { }\n\n# after\n# Rocket.toml\n[default.limits]\nmsgpack = \"10 MiB\"\n\n#[post(\"/ingest\", data = \"<batch>\")]\nfn ingest(batch: MsgPack<Batch>) { }","handlingStrategy":"try-catch","validationCode":"// pre-check size for msgpack uploads\n#[post(\"/ingest\", data = \"<data>\")]\nfn ingest(req: &Request<'_>, data: Data<'_>) -> Status {\n    let limit: usize = 10 * 1024 * 1024;\n    if let Some(len) = req.headers().get_one(\"Content-Length\").and_then(|v| v.parse::<usize>().ok()) {\n        if len > limit { return Status::PayloadTooLarge; }\n    }\n    Status::Ok\n}","typeGuard":null,"tryCatchPattern":"// server: catcher translating guard failure for msgpack clients\n#[catch(413)]\nfn too_large(_: &Request) -> (Status, &('static str)) {\n    (Status::PayloadTooLarge, \"msgpack body exceeds configured limit\")\n}","preventionTips":["Set limits.msgpack deliberately when accepting packed binary batches","Chunk large binary streams instead of one giant msgpack document","Monitor 413 rates to catch payload growth before clients do"],"tags":["rust","rocket","msgpack","limits","runtime","request-body"],"backgroundTag":"request-body-too-large","analyzedSha":"3a54d079aef060a8f732bd04ea54b0581a604087","analyzedAt":"2026-08-16T22:01:48.395Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}