{"record":{"id":"8b0404af2449d2c5","repo":"BoundaryML/baml","slug":"internal-error-0-8b0404","errorCode":null,"errorMessage":"internal error: {0}","messagePattern":"internal error: (.+?)","errorType":"exception","errorClass":"BamlError","httpStatus":null,"severity":"error","filePath":"languages/rust/baml/src/error.rs","lineNumber":10,"sourceCode":"use std::collections::HashMap;\n\n/// BAML runtime errors\n///\n/// Note: This is intentionally minimal. Expand with specific variants\n/// (`InitError`, `CallError`, etc.) once the core functionality works.\n#[derive(Debug, thiserror::Error, Clone)]\npub enum BamlError {\n    /// Internal/unexpected errors - bugs in BAML that should never happen\n    #[error(\"internal error: {0}\")]\n    Internal(String),\n\n    /// Type check errors - expected runtime failures (type mismatches)\n    #[error(\"type error: expected {expected}, got {got}\")]\n    TypeCheck { expected: String, got: String },\n}\n\n/// Trait for types that can report their full type name for error messages.\n/// Used by `BamlValue` variants to provide descriptive \"got\" values.\npub trait FullTypeName {\n    fn full_type_name(&self) -> String;\n}\n\nimpl BamlError {\n    /// Create an internal error for unexpected bugs\n    pub fn internal(msg: impl Into<String>) -> Self {\n        BamlError::Internal(msg.into())\n    }","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/languages/rust/baml/src/error.rs#L1-L28","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"matches!(err, BamlError::Internal(_))","tryCatchPattern":"match runtime.call_function(\"MyFunc\", &inputs) {\n    Err(BamlError::Internal(detail)) => {\n        log::error!(\"baml internal error: {detail}\");\n        // escalate / report bug\n    }\n    r => r?,\n}","preventionTips":["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."],"tags":["rust","internal","bug","baml"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}