{"record":{"id":"a0ac8937df35f2b8","repo":"BoundaryML/baml","slug":"internal-error-0-a0ac89","errorCode":null,"errorMessage":"Internal error: {0}","messagePattern":"Internal error: (.+?)","errorType":"error_code","errorClass":"CtypesError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bridge_ctypes/src/error.rs","lineNumber":39,"sourceCode":"    /// blobs can be up to the FFI decode cap (~67M chars), and embedding\n    /// them in error messages bloats logs and exposes payload contents.\n    #[error(\"Invalid bigint hex string ({len} bytes)\")]\n    InvalidBigint { len: usize },\n\n    /// Carries only the input length for over-cap decimal type literals, so a\n    /// hostile descriptor cannot amplify logs by echoing its full payload.\n    #[error(\"Invalid decimal bigint literal ({len} bytes)\")]\n    InvalidBigintLiteral { len: usize },\n\n    #[error(\n        \"Invalid InboundValue.value_type: a root union or optional does not identify one exact selected type\"\n    )]\n    InvalidInboundValueTypeRootUnion,\n\n    #[error(\"Union selected type `{selected}` is not a member of declared union `{union}`\")]\n    UnionSelectedTypeNotMember { selected: String, union: String },\n\n    #[error(\"Internal error: {0}\")]\n    InternalError(String),\n}\n","sourceCodeStart":21,"sourceCodeEnd":42,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bridge_ctypes/src/error.rs#L21-L42","documentation":"This is an internal panic-style error from the bridge_ctypes error enum, used when the FFI boundary code reaches a state that should be impossible. The library throws it to signal a bug in the bridge (not user error), carrying a descriptive string about the invariant that was violated. If you see it, the typed bridge layer misused its own contracts.","triggerScenarios":"Calling generated bridge functions when an internal invariant in the ctypes bridge is violated, e.g. a value shape or enum discriminant the conversion layer did not expect reaches the boundary.","commonSituations":"Usually surfaces after a version mismatch between generated bindings and the native library, or when bypassing generated wrappers and calling raw ctypes entry points directly with hand-built values.","solutions":["Check that your generated bindings and the native bridge library are built from the same version","Stop calling raw ctypes functions directly; use the generated wrapper API","Reproduce with a minimal snippet and file a bug report with the internal error message string","Clear stale build artifacts and rebuild the bridge"],"exampleFix":"// before\nlib.baml_call_raw(unvalidated_buffer)\n// after\nfrom baml_bridge import Client\nclient = Client.from_source(src)\nclient.call(request)  # goes through validated generated wrappers","handlingStrategy":"try-catch","validationCode":"import ctypes_bridge_meta as meta\nassert meta.__version__ == native_bridge_version(), 'binding/native version mismatch'","typeGuard":"function isInternalError(e) {\n  return e instanceof Error && e.name === 'BamlInternalError' && /Internal error:/.test(e.message);\n}","tryCatchPattern":"try {\n  result = bridge.call(req);\n} catch (e) {\n  if (isInternalError(e)) {\n    logBugReport(e.message);\n    throw new Error('Bridge internal error — report bug, check version match');\n  }\n  throw e;\n}","preventionTips":["Always regenerate bindings and rebuild the native lib together","Never call raw ctypes symbols directly; use generated wrappers","Pin bridge library versions in lockfiles","Rebuild from clean artifacts after upgrading"],"tags":["ffi","internal","bridge"],"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"}