{"record":{"id":"30da49eb614bd725","repo":"BoundaryML/baml","slug":"unexpected-type-for-log-type-t","errorCode":null,"errorMessage":"unexpected type for log type: %T","messagePattern":"unexpected type for log type: %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_function_log.go","lineNumber":63,"sourceCode":"\t}\n\n\tname, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for function name: %T\", result)\n\t}\n\n\treturn name, nil\n}\n\nfunc (f *functionLog) LogType() (string, error) {\n\tresult, err := raw_objects.CallMethod(f, \"log_type\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get log type: %w\", err)\n\t}\n\n\tlogType, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for log type: %T\", result)\n\t}\n\n\treturn logType, nil\n}\n\nfunc (f *functionLog) Timing() (Timing, error) {\n\tresult, err := raw_objects.CallMethod(f, \"timing\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get timing: %w\", err)\n\t}\n\n\ttiming, ok := result.(Timing)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for timing: %T\", result)\n\t}\n\n\treturn timing, nil\n}","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_function_log.go#L45-L81","documentation":"Returned by LogType() when the 'log_type' call succeeded but the decoded value failed the `result.(string)` assertion, meaning the runtime returned a non-string Go value. This guards the FFI contract between the Go client and the Rust BAML runtime; hitting it implies the runtime's representation of log_type differs from what the client expects — a contract/version mismatch or object corruption, not a user input problem.","triggerScenarios":"The Rust runtime decodes log_type into a non-string object; client/runtime version skew changing field representation; corrupted stale functionLog objects.","commonSituations":"Mixing a newer BAML engine with an older generated Go client; reusing logs after stream teardown; a decodeObjectResponse variant bug.","solutions":["Regenerate the Go client (`baml generate`) to match the installed BAML runtime.","Note the %T type printed in the message to identify what was actually returned.","Use the log only while its function stream is valid; recreate access from the live response.","File a bug with BAML (include the printed Go type and versions) if it occurs on a fresh, valid object."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if fnLog == nil {\n    return errors.New(\"function log is nil; cannot read LogType\")\n}","typeGuard":"func logTypeIsString(v any) (string, bool) {\n    s, ok := v.(string)\n    return s, ok\n}","tryCatchPattern":"lt, err := fnLog.LogType()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type for log type:\") {\n        return \"\", fmt.Errorf(\"log_type contract mismatch (check client/runtime versions): %w\", err)\n    }\n    return \"\", err\n}","preventionTips":["Keep generated client and BAML runtime in version lockstep.","Capture the %T value from the message for diagnostics.","Use logs only while their owning stream is valid.","File upstream bugs with the printed type and versions when it recurs."],"tags":["go","ffi","type-mismatch","baml"],"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"}