{"record":{"id":"c53af6f7020ff15b","repo":"BoundaryML/baml","slug":"unexpected-type-in-logs-t","errorCode":null,"errorMessage":"unexpected type in logs: %T","messagePattern":"unexpected type in logs: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_collector.go","lineNumber":70,"sourceCode":"\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)\n\t}\n\n\tif result == nil {\n\t\treturn nil, nil\n\t}\n\n\tlog, ok := result.(FunctionLog)","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_collector.go#L52-L88","documentation":"Thrown inside Collector.Logs() at rawobjects_collector.go:70 when an element of the returned []raw_objects.RawPointer slice fails the FunctionLog interface assertion. The runtime returned a log slice containing an object that is not a FunctionLog (e.g. an LLM call log of a different kind).","triggerScenarios":"collector.Logs() where the collector holds raw objects registered under a type that does not implement FunctionLog.","commonSituations":"Version drift between the Go bindings and the native runtime causing raw objects to be wrapped with the wrong Go adapter; passing a Collector used for non-function traces.","solutions":["Match Go client and native runtime versions (rebuild).","Inspect the %T in the message to identify which concrete type leaked in.","Report upstream if versions match — this is an internal invariant."],"exampleFix":"// before\nlogs, _ := collector.Logs()\n// after\nlogs, err := collector.Logs()\nif err != nil {\n\treturn fmt.Errorf(\"collector logs unusable: %w\", err)\n}","handlingStrategy":"type-guard","validationCode":"if collector == nil { return errors.New(\"collector not initialized\") }","typeGuard":"func firstLog(c baml.Collector) (baml.FunctionLog, bool) {\n\tlogs, err := c.Logs()\n\tif err != nil || len(logs) == 0 { return nil, false }\n\treturn logs[0], true\n}","tryCatchPattern":"logs, err := collector.Logs()\nvar bad baml.FunctionLog\n_ = bad\nif err != nil { return fmt.Errorf(\"logs unavailable: %w\", err) }","preventionTips":["Keep Go bindings and native runtime versions in lockstep.","Treat 'unexpected type' errors as bugs, not retryable failures.","Include the %T from the message in bug reports."],"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"}