{"record":{"id":"7b02270ea745d885","repo":"BoundaryML/baml","slug":"unexpected-type-for-logs-t","errorCode":null,"errorMessage":"unexpected type for logs: %T","messagePattern":"unexpected type for logs: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_collector.go","lineNumber":63,"sourceCode":"\t}\n\n\tname, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for name: %T\", result)\n\t}\n\n\treturn name, nil\n}\n\nfunc (c *collector) Logs() ([]FunctionLog, error) {\n\tresult, err := raw_objects.CallMethod(c, \"logs\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get logs: %w\", err)\n\t}\n\n\tlogs, ok := result.([]raw_objects.RawPointer)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for logs: %T\", result)\n\t}\n\n\tfunctionLogs := make([]FunctionLog, len(logs))\n\tfor i, log := range logs {\n\t\tcast, ok := log.(FunctionLog)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"unexpected type in logs: %T\", log)\n\t\t}\n\t\tfunctionLogs[i] = cast\n\t}\n\n\treturn functionLogs, nil\n}\n\nfunc (c *collector) Last() (FunctionLog, error) {\n\tresult, err := raw_objects.CallMethod(c, \"last\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get last log: %w\", err)","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_collector.go#L45-L81","documentation":"Thrown by Collector.Logs() in engine/language_client_go/pkg/rawobjects_collector.go:63 when the underlying FFI CallMethod(\"logs\") returns a value that is not a []raw_objects.RawPointer slice. The BAML Go client unmarshals raw C++ collector objects into typed Go values; if the runtime returns something unexpected, this internal type-assertion guard fires. It almost always indicates an FFI/version mismatch or a corrupted raw object rather than user error.","triggerScenarios":"Calling collector.Logs() when the BAML runtime's 'logs' method returns a non-slice raw object — typically from a version mismatch between the Go client and the native BAML runtime, or a raw object registered under the wrong object type.","commonSituations":"Mixed-version baml-go bindings and native binaries; upgrading the BAML runtime without rebuilding the Go client; corrupted Collector handle after runtime restart.","solutions":["Ensure the Go baml client version matches the native BAML runtime/binary version; rebuild and re-link.","Upgrade github.com/boundaryml/baml Go package and regenerate any BAML client code.","If reproducible, file a bug with the %T value printed in the message."],"exampleFix":"// before\nlogs, err := collector.Logs()\n// after\nlogs, err := collector.Logs()\nif err != nil {\n\tvar te *baml.TypeMismatchError\n\tif errors.As(err, &te) { /* runtime/client version mismatch: reinstall matching baml binaries */ }\n}","handlingStrategy":"type-guard","validationCode":"if collector == nil { return errors.New(\"collector not initialized\") }","typeGuard":"func safeLogs(c baml.Collector) ([]baml.FunctionLog, bool) {\n\tlogs, err := c.Logs()\n\tif err != nil { return nil, false }\n\treturn logs, true\n}","tryCatchPattern":"logs, err := collector.Logs()\nif err != nil {\n\tif strings.Contains(err.Error(), \"unexpected type\") {\n\t\t// Go client / native runtime version mismatch: fail fast with guidance\n\t}\n\treturn err\n}","preventionTips":["Pin the BAML Go client and native binary to the same version.","Rebuild the client after upgrading the BAML runtime.","Log the full error (it includes the offending %T) when filing bugs."],"tags":["go","ffi","type-mismatch","collector"],"backgroundTag":"type-mismatch","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}