BoundaryML/baml · critical

======================================== BAML Internal…

Error message


========================================
BAML Internal Error
========================================

{}

This is a bug in BAML. Please report it:
- GitHub: https://github.com/BoundaryML/baml/issues
- Discord: https://boundaryml.com/discord

Include this error message and steps to reproduce.
========================================

What it means

The baml_unreachable! macro panics with a formatted banner marking code that should be impossible to reach. It's a deliberate fail-fast for internal invariant violations, and instructs the developer to report the bug to BAML's GitHub or Discord.

Solutions

  1. Capture the full panic message including the formatted payload — it identifies the unhandled case.
  2. Upgrade to the latest baml crate version, which may handle the new variant.
  3. Open an issue at https://github.com/BoundaryML/baml/issues with the message and reproduction steps (or ask on https://boundaryml.com/discord).

Example fix

// before (in user code)
match value { _ => unreachable!() }
// after: upgrade dependency and reproduce with a minimal .baml + input, then report
// Cargo.toml
// baml = "<latest>"
Defensive patterns

Strategy: try-catch

Try / catch

let result = std::panic::catch_unwind(|| baml_runtime.run(...));
if let Err(panic) = result {
    let msg = panic.downcast_ref::<String>().cloned().unwrap_or_default();
    if msg.contains("BAML Internal Error") {
        // capture msg, versions, and repro; file issue at BoundaryML/baml
    }
}

Prevention

When it happens

Trigger: Any match arm or branch marked baml_unreachable!(...) being executed at runtime — e.g. baml_unreachable!("unknown object type: {:?}", obj_type) when the runtime encounters an unhandled value variant or state.

Common situations: New enum variants added upstream but not yet handled in the Rust bindings; corrupted or version-mismatched serialized data introducing unexpected values; genuine BAML bugs.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/d963b01fee0a0c80. Report an issue: GitHub.

Appendix: source

Thrown at languages/rust/baml/src/error.rs:201

/// Panics with a user-friendly error message for internal/unreachable errors.
///
/// This macro is used for situations that should never occur in practice -
/// bugs in the FFI boundary, protocol mismatches, etc. The error message
/// guides users to report the issue.
///
/// # Examples
/// ```ignore
/// // Simple message
/// baml_unreachable!("unexpected null pointer");
///
/// // With format args
/// baml_unreachable!("unknown object type: {:?}", obj_type);
/// ```
#[macro_export]
macro_rules! baml_unreachable {
    ($($arg:tt)*) => {{
        panic!(
            "\n\n\
            ========================================\n\
            BAML Internal Error\n\
            ========================================\n\n\
            {}\n\n\
            This is a bug in BAML. Please report it:\n\
            - GitHub: https://github.com/BoundaryML/baml/issues\n\
            - Discord: https://boundaryml.com/discord\n\n\
            Include this error message and steps to reproduce.\n\
            ========================================\n",
            format_args!($($arg)*)
        )
    }};
}

View on GitHub (pinned to bd85ce9dee)