{"record":{"id":"b893c5cc7b164396","repo":"BoundaryML/baml","slug":"unexpected-type-for-log-by-id-t","errorCode":null,"errorMessage":"unexpected type for log by id: %T","messagePattern":"unexpected type for log by id: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_collector.go","lineNumber":106,"sourceCode":"\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\n\treturn log, nil\n}\n\nfunc (c *collector) Clear() (int64, error) {\n\tresult, err := raw_objects.CallMethod(c, \"clear\", nil)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to clear: %w\", err)\n\t}\n\n\tcount, ok := result.(int64)\n\tif !ok {\n\t\treturn 0, fmt.Errorf(\"unexpected type for clear result: %T\", result)\n\t}\n\n\treturn count, nil\n}","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_collector.go#L88-L124","documentation":"Go type-assertion failure in the collector's Id method: the raw-objects bridge returned a value for the log lookup, but it is not a FunctionLog as Go expects (the %T shows the actual concrete type). This indicates a protocol mismatch between the Go bindings and the runtime version that answered the call.","triggerScenarios":"collector.Id(...) where the native runtime returns a non-FunctionLog raw object for the given id — wrong object kind registered, or Go/native version mismatch.","commonSituations":"Version skew between Go bindings and native BAML runtime; runtime bug mapping the resolved object to the wrong Go adapter.","solutions":["Rebuild with matching Go client and native runtime versions.","Inspect the %T in the message for the leaked type.","Report upstream if it persists on matched versions."],"exampleFix":"// before\nlog, _ := collector.Id(fnId)\n// after\nlog, err := collector.Id(fnId)\nif err != nil {\n\treturn err\n}\nvar _ baml.FunctionLog = log // compile-time sanity","handlingStrategy":"type-guard","validationCode":"if functionId == \"\" { return errors.New(\"functionId required\") }","typeGuard":"func logById(c baml.Collector, id string) (baml.FunctionLog, bool) {\n\tl, err := c.Id(id)\n\tif err != nil { return nil, false }\n\treturn l, true\n}","tryCatchPattern":"log, err := collector.Id(functionId)\nif err != nil {\n\tif strings.Contains(err.Error(), \"unexpected type\") { /* internal bug / version skew */ }\n\treturn err\n}","preventionTips":["Keep client and runtime versions aligned.","Report persistent %T mismatches upstream with the type name.","Prefer iterating Logs() over Id() when unsure of valid ids."],"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"}