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

MissingLevelField

Error message

MissingLevelField

What it means

Sentinel variant of the install Error enum: while validating an advisory from the security scanner, its JSON lacks the required severity 'level' field. One of the advisory-schema validation variants (alongside InvalidPackageField, InvalidDescriptionField, etc.) guarding the scanner's output shape.

Solutions

  1. Re-run `bun pm audit`; malformed advisories can come from a truncated registry response
  2. Update Bun to pick up audit parsing fixes
  3. Report persistent malformed audit data to Bun's issues

Example fix

// before
advisories: [{ package: "foo", severity: "high" }]

// after
const level = (s) => (s === "critical" || s === "high" ? "fatal" : "warn");
advisories: [{ package: "foo", level: level("high") }]
Defensive patterns

Strategy: validation

Validate before calling

// scanner-side: every advisory must carry a level before sending
const LEVELS = new Set(["fatal", "warn"]);
const advisories = raw.filter((a) => LEVELS.has(a.level));

Type guard

const hasLevel = (a) => a?.level === "fatal" || a?.level === "warn";

Prevention

When it happens

Trigger: Scanner emits {"package":"foo","description":"..."} with no level, or uses an alternative key like "severity"/"impact" that Bun ignores.

Common situations: Porting advisories from npm audit (which uses "severity": "high"); scanners whose schema uses severity buckets that were never mapped to fatal/warn.

Related errors


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

Appendix: source

Thrown at src/install/error.rs:139

    #[error("SecurityScannerFailed")]
    SecurityScannerFailed,
    #[error("SecurityScannerTerminated")]
    SecurityScannerTerminated,
    #[error("InvalidAdvisoriesFormat")]
    InvalidAdvisoriesFormat,
    #[error("InvalidAdvisoryFormat")]
    InvalidAdvisoryFormat,
    #[error("MissingPackageField")]
    MissingPackageField,
    #[error("InvalidPackageField")]
    InvalidPackageField,
    #[error("EmptyPackageField")]
    EmptyPackageField,
    #[error("InvalidDescriptionField")]
    InvalidDescriptionField,
    #[error("InvalidUrlField")]
    InvalidUrlField,
    #[error("MissingLevelField")]
    MissingLevelField,
    #[error("InvalidLevelField")]
    InvalidLevelField,
    #[error("InvalidLevelValue")]
    InvalidLevelValue,
    #[error("Missing global bin directory: try setting $BUN_INSTALL")]
    MissingGlobalBinDirectoryTrySettingBUNINSTALL,
    #[error("InvalidURL")]
    InvalidURL,
    #[error("Fail")]
    Fail,
    #[error("IntegrityCheckFailed")]
    IntegrityCheckFailed,
    #[error("RepositoryNotFound")]
    RepositoryNotFound,
    #[error("DebugTextLockfileRoundTrip")]
    DebugTextLockfileRoundTrip,
    #[error("NoPackage")]

View on GitHub (pinned to 8c5296ac45)