{"record":{"id":"a510960c871cbbc9","repo":"BoundaryML/baml","slug":"unexpected-type-for-bool-type-t","errorCode":null,"errorMessage":"unexpected type for bool type: %T","messagePattern":"unexpected type for bool type: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_type_builder.go","lineNumber":75,"sourceCode":"\t}\n\n\ttyp, ok := result.(Type)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for float type: %T\", result)\n\t}\n\n\treturn typ, nil\n}\n\nfunc (tb *typeBuilder) Bool() (Type, error) {\n\tresult, err := raw_objects.CallMethod(tb, \"bool\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttyp, ok := result.(Type)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for bool type: %T\", result)\n\t}\n\n\treturn typ, nil\n}\n\nfunc (tb *typeBuilder) Null() (Type, error) {\n\tresult, err := raw_objects.CallMethod(tb, \"null\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttyp, ok := result.(Type)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for null type: %T\", result)\n\t}\n\n\treturn typ, nil\n}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_type_builder.go#L57-L93","documentation":"typeBuilder.Bool() calls the FFI method \"bool\" and asserts the result implements the baml Type interface. When the bridge returns a value that is not a Type implementation, the assertion fails with this error. This is an internal decode/wrapping failure between the native BAML runtime and the Go bindings.","triggerScenarios":"Calling TypeBuilder.Bool() when the underlying \"bool\" method returns an unwrapped raw object or nil instead of a Type.","commonSituations":"Go bindings out of sync with the native runtime; stale or custom-generated cffi wrapper registry; TypeBuilder created from an incompatible runtime instance.","solutions":["Check %T in the error to identify what the bridge returned.","Update the baml Go module to match your native BAML runtime version.","Regenerate wrapper code if using a from-source build.","Escalate to boundaryml/baml with the printed type if versions are aligned."],"exampleFix":"// before\nboolTyp, err := tb.Bool()\nif err != nil {\n    return err\n}\n\n// after\nboolTyp, err := tb.Bool()\nif err != nil {\n    return fmt.Errorf(\"bool type build failed (verify baml Go bindings match native runtime): %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"if tb == nil {\n    return errors.New(\"type builder is nil\")\n}","typeGuard":"func isBamlType(v any) bool { _, ok := v.(baml.Type); return ok }","tryCatchPattern":"typ, err := tb.Bool()\nif err != nil {\n    log.Printf(\"Bool() decode failure: %v\", err)\n    return fmt.Errorf(\"bool type build failed: %w\", err)\n}","preventionTips":["Keep baml Go bindings and native runtime on matching versions.","Add type-builder basic-type tests to your upgrade checklist.","Capture %T from the error message for diagnostics."],"tags":["go","ffi","type-builder","type-mismatch"],"backgroundTag":"type-mismatch","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"}