{"record":{"id":"6440b4c14ebb0804","repo":"BoundaryML/baml","slug":"unexpected-type-for-last-log-t-v","errorCode":null,"errorMessage":"unexpected type for last log: %T %v","messagePattern":"unexpected type for last log: %T (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_collector.go","lineNumber":90,"sourceCode":"\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)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for last log: %T %v\", result, result)\n\t}\n\n\treturn log, nil\n}\n\nfunc (c *collector) Id(functionId string) (FunctionLog, error) {\n\tresult, err := raw_objects.CallMethod(c, \"id\", map[string]any{\n\t\t\"id\": functionId,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get log by id: %w\", err)\n\t}\n\n\tlog, ok := result.(FunctionLog)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for log by id: %T\", result)\n\t}\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_collector.go#L72-L108","documentation":"Thrown by Collector.Last() at rawobjects_collector.go:90 when CallMethod(\"last\") returns a non-nil value that does not implement the FunctionLog interface. The runtime returned an object of the wrong kind for 'last'.","triggerScenarios":"collector.Last() where the native runtime returns a raw object wrapped as something other than a FunctionLog (version mismatch or wrong object registration).","commonSituations":"Go bindings/native runtime version skew; runtime returning an internal object type not mapped to FunctionLog in the Go layer.","solutions":["Align Go client and native runtime versions; rebuild.","Check the printed %T to identify the leaked concrete type.","File an upstream bug with the type name if versions match."],"exampleFix":"// before\nlog, _ := collector.Last()\n// after\nlog, err := collector.Last()\nif err != nil {\n\treturn fmt.Errorf(\"collector.Last() type error: %w\", err)\n}","handlingStrategy":"type-guard","validationCode":"if collector == nil { return errors.New(\"collector not initialized\") }","typeGuard":"func asLog(v any) (baml.FunctionLog, bool) {\n\tl, ok := v.(baml.FunctionLog)\n\treturn l, ok\n}","tryCatchPattern":"log, err := collector.Last()\nif err != nil {\n\tif strings.Contains(err.Error(), \"unexpected type\") { /* version mismatch — escalate */ }\n\treturn err\n}","preventionTips":["Match Go client and native runtime versions.","Do not reuse collectors across runtime instances.","Escalate persistent occurrences as upstream 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"}