oven-sh/bun · error · HpackError

UnableToEncode

UnableToEncode

Error message

UnableToEncode

What it means

Error "UnableToEncode" thrown in oven-sh/bun.

Source

Thrown at src/http/lshpack.rs:49

pub struct DecodeResult {
    // TODO: lifetime — name/value point into an FFI thread_local shared buffer,
    // valid only until the next decode/encode call. Consider `DecodeResult<'a>`.
    pub name: &'static [u8],
    pub value: &'static [u8],
    pub never_index: bool,
    pub well_know: u16,
    /// offset of the next header position in src
    pub next: usize,
}

#[derive(thiserror::Error, strum::IntoStaticStr, Debug, Clone, Copy, PartialEq, Eq)]
pub enum HpackError {
    #[error("UnableToDecode")]
    UnableToDecode,
    #[error("EmptyHeaderName")]
    EmptyHeaderName,
    #[error("UnableToEncode")]
    UnableToEncode,
}

impl HPACK {
    /// DecodeResult name and value uses a thread_local shared buffer and should be copy/cloned before the next decode/encode call
    pub fn decode(&mut self, src: &[u8]) -> Result<DecodeResult, HpackError> {
        let mut header = lshpack_header::default();
        // SAFETY: genuine FFI — only the `(src.as_ptr(), src.len())` pair carries
        // an obligation here (in-bounds read), discharged by `src: &[u8]`. The
        // `self`/`output` preconditions are type-discharged via `&mut` in the
        // extern signature.
        let offset = unsafe { lshpack_wrapper_decode(self, src.as_ptr(), src.len(), &mut header) };
        if offset == 0 {
            return Err(HpackError::UnableToDecode);
        }
        if header.name_len == 0 {
            return Err(HpackError::EmptyHeaderName);
        }

View on GitHub (pinned to 8c5296ac45)

When it happens

Trigger: Thrown at src/http/lshpack.rs:49 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/af888c057157c6cf. Report an issue: GitHub.