BoundaryML/baml · error · BamlError
internal error
Error message
internal error: {0} What it means
BamlError::Internal is the catch-all variant for unexpected internal errors in the Rust BAML bindings — situations that indicate a bug in BAML rather than user error. It renders as "internal error: <detail>" via thiserror. The crate docs note it is intentionally minimal until more specific variants are added.
Solutions
- Read the wrapped detail string — it usually names the unexpected value or state.
- Update the baml crate and regenerate the client to align versions.
- If reproducible with minimal input, file a bug at https://github.com/BoundaryML/baml/issues.
Defensive patterns
Strategy: try-catch
Type guard
matches!(err, BamlError::Internal(_))
Try / catch
match runtime.call_function("MyFunc", &inputs) {
Err(BamlError::Internal(detail)) => {
log::error!("baml internal error: {detail}");
// escalate / report bug
}
r => r?,
} Prevention
- Keep the baml crate and generated clients on matching versions.
- Report reproducible Internal errors upstream with minimal inputs.
- Avoid constructing BamlValue by hand where generated types exist.
When it happens
Trigger: Any code path in languages/rust/baml that constructs BamlError::Internal(String), typically from panics converted to errors, unmatched enum arms, or invariant violations surfaced through the public runtime API.
Common situations: Using a pre-release Rust binding where core functionality is incomplete; feeding BAML values/shapes the runtime doesn't recognize; version mismatch between the generated client and the baml runtime crate.
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
- ======================================== BAML Internal…
- internal error: cannot convert value
- internal error: cannot convert value
- {0}
- BAML Generate failed - Project has errors.
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/8b0404af2449d2c5.
Report an issue: GitHub.
Appendix: source
Thrown at languages/rust/baml/src/error.rs:10
use std::collections::HashMap;
/// BAML runtime errors
///
/// Note: This is intentionally minimal. Expand with specific variants
/// (`InitError`, `CallError`, etc.) once the core functionality works.
#[derive(Debug, thiserror::Error, Clone)]
pub enum BamlError {
/// Internal/unexpected errors - bugs in BAML that should never happen
#[error("internal error: {0}")]
Internal(String),
/// Type check errors - expected runtime failures (type mismatches)
#[error("type error: expected {expected}, got {got}")]
TypeCheck { expected: String, got: String },
}
/// Trait for types that can report their full type name for error messages.
/// Used by `BamlValue` variants to provide descriptive "got" values.
pub trait FullTypeName {
fn full_type_name(&self) -> String;
}
impl BamlError {
/// Create an internal error for unexpected bugs
pub fn internal(msg: impl Into<String>) -> Self {
BamlError::Internal(msg.into())
}View on GitHub (pinned to bd85ce9dee)