oven-sh/bun · error · Error

InvalidPEFile

Error message

InvalidPEFile

What it means

PE error variant: generic structural validation of the portable executable failed — the file did not pass the PE/COFF header sanity checks beyond the DOS signature (bad e_lfanew, missing PE signature, or invalid optional-header layout). It means the input is not a usable PE image.

Solutions

  1. Confirm the input is a valid Windows PE executable of the expected architecture
  2. Rebuild the target executable; structural PE failures usually indicate a broken artifact
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/exe_format/pe.rs:17 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/497c3ad944de5160. Report an issue: GitHub.

Appendix: source

Thrown at src/exe_format/pe.rs:17

// Windows PE sections use standard file alignment (typically 512 bytes)
// No special 16KB alignment needed like macOS code signing

use core::mem::{offset_of, size_of};
use core::ptr;
use core::slice;

// New error types for PE manipulation
#[derive(thiserror::Error, strum::IntoStaticStr, Debug, Copy, Clone, Eq, PartialEq)]
pub enum Error {
    #[error("OutOfBounds")]
    OutOfBounds,
    #[error("BadAlignment")]
    BadAlignment,
    #[error("Overflow")]
    Overflow,
    #[error("InvalidPEFile")]
    InvalidPEFile,
    #[error("InvalidDOSSignature")]
    InvalidDOSSignature,
    #[error("InvalidPESignature")]
    InvalidPESignature,
    #[error("UnsupportedPEFormat")]
    UnsupportedPEFormat,
    #[error("InsufficientHeaderSpace")]
    InsufficientHeaderSpace,
    #[error("TooManySections")]
    TooManySections,
    #[error("SectionExists")]
    SectionExists,
    #[error("InputIsSigned")]
    InputIsSigned,
    #[error("InvalidSecurityDirectory")]
    InvalidSecurityDirectory,
    #[error("SecurityDirInsideImage")]

View on GitHub (pinned to 8c5296ac45)