{"record":{"id":"af888c057157c6cf","repo":"oven-sh/bun","slug":"unabletoencode","errorCode":"UnableToEncode","errorMessage":"UnableToEncode","messagePattern":"UnableToEncode","errorType":"exception","errorClass":"HpackError","httpStatus":null,"severity":"error","filePath":"src/http/lshpack.rs","lineNumber":49,"sourceCode":"\npub struct DecodeResult {\n    // TODO: lifetime — name/value point into an FFI thread_local shared buffer,\n    // valid only until the next decode/encode call. Consider `DecodeResult<'a>`.\n    pub name: &'static [u8],\n    pub value: &'static [u8],\n    pub never_index: bool,\n    pub well_know: u16,\n    /// offset of the next header position in src\n    pub next: usize,\n}\n\n#[derive(thiserror::Error, strum::IntoStaticStr, Debug, Clone, Copy, PartialEq, Eq)]\npub enum HpackError {\n    #[error(\"UnableToDecode\")]\n    UnableToDecode,\n    #[error(\"EmptyHeaderName\")]\n    EmptyHeaderName,\n    #[error(\"UnableToEncode\")]\n    UnableToEncode,\n}\n\nimpl HPACK {\n    /// DecodeResult name and value uses a thread_local shared buffer and should be copy/cloned before the next decode/encode call\n    pub fn decode(&mut self, src: &[u8]) -> Result<DecodeResult, HpackError> {\n        let mut header = lshpack_header::default();\n        // SAFETY: genuine FFI — only the `(src.as_ptr(), src.len())` pair carries\n        // an obligation here (in-bounds read), discharged by `src: &[u8]`. The\n        // `self`/`output` preconditions are type-discharged via `&mut` in the\n        // extern signature.\n        let offset = unsafe { lshpack_wrapper_decode(self, src.as_ptr(), src.len(), &mut header) };\n        if offset == 0 {\n            return Err(HpackError::UnableToDecode);\n        }\n        if header.name_len == 0 {\n            return Err(HpackError::EmptyHeaderName);\n        }","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/http/lshpack.rs#L31-L67","documentation":"Error \"UnableToEncode\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at src/http/lshpack.rs:49 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}