oven-sh/bun · error · bun_core::Error

InvalidByteSequence

Error message

InvalidByteSequence

What it means

Sentinel variant of the bun_core generic Error enum: a byte-oriented decoder (e.g. UTF-8 or another string decoder) encountered an input sequence that is invalid for the expected encoding. Generic malformed-input guard; the position/context is carried by the call site, not the message.

Solutions

  1. Validate/lossy-convert the input encoding before the strict path
  2. Check for byte truncation in the source buffer
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/bun_core/error.rs:11 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/c8990593d2ebc59c. Report an issue: GitHub.

Appendix: source

Thrown at src/bun_core/error.rs:11

#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
pub enum Error {
    #[error("EndOfStream")]
    EndOfStream,
    #[error("StreamTooLong")]
    StreamTooLong,
    #[error("FmtError")]
    FmtError,
    #[error("Unexpected")]
    Unexpected,
    #[error("InvalidByteSequence")]
    InvalidByteSequence,
    #[error("StringTooLong")]
    StringTooLong,
    #[error("InvalidCharacter")]
    InvalidCharacter,
    // errno-category names kept local (bun_core cannot depend on bun_errno):
    #[error("NoSpaceLeft")]
    NoSpaceLeft,
    #[error("NameTooLong")]
    NameTooLong,
    #[error("FileNotFound")]
    FileNotFound,
    #[error("AccessDenied")]
    AccessDenied,
    #[error("WriteFailed")]
    WriteFailed,
    #[error("CurrentWorkingDirectoryUnlinked")]
    CurrentWorkingDirectoryUnlinked,

View on GitHub (pinned to 8c5296ac45)