{"record":{"id":"45fadcef4db26df0","repo":"BoundaryML/baml","slug":"unexpected-type-for-float-type-t","errorCode":null,"errorMessage":"unexpected type for float type: %T","messagePattern":"unexpected type for float type: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_type_builder.go","lineNumber":61,"sourceCode":"\t}\n\n\ttyp, ok := result.(Type)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for int type: %T\", result)\n\t}\n\n\treturn typ, nil\n}\n\nfunc (tb *typeBuilder) Float() (Type, error) {\n\tresult, err := raw_objects.CallMethod(tb, \"float\", 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 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}","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_type_builder.go#L43-L79","documentation":"typeBuilder.Float() calls the FFI method \"float\" and asserts the result implements the baml Type interface. If the bridge returns any other value (unwrapped pointer, nil, wrong wrapper), this error is thrown. It means the native side built the float type but the Go bindings could not decode it into a Type.","triggerScenarios":"Calling TypeBuilder.Float() when the underlying \"float\" method returns a non-Type object from the bridge.","commonSituations":"Mismatched baml Go module and native runtime versions; wrapper registry lacking the mapping for the returned object type; custom builds with stale generated code.","solutions":["Read %T in the error message to see what the decoder actually produced.","Align the baml Go dependency version with the native BAML runtime.","Regenerate cffi bindings if you build BAML from source.","Report upstream with the printed type if versions already match."],"exampleFix":"// before\nfloatTyp, err := tb.Float()\nif err != nil {\n    return err\n}\n\n// after\ndoubleTyp, err := tb.Float()\nif err != nil {\n    return fmt.Errorf(\"float type build failed (check baml binding/runtime versions): %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.Float()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type for float type\") {\n        return fmt.Errorf(\"float type decode failed - verify baml binding/runtime versions: %w\", err)\n    }\n    return err\n}","preventionTips":["Smoke-test all TypeBuilder basic-type methods in CI after upgrades.","Avoid mixing TypeBuilder instances across runtime versions.","Include the %T payload in upstream bug reports."],"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"}