{"record":{"id":"97ac656a1cc8cc96","repo":"BoundaryML/baml","slug":"unexpected-type-for-timing-t","errorCode":null,"errorMessage":"unexpected type for timing: %T","messagePattern":"unexpected type for timing: %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_function_log.go","lineNumber":77,"sourceCode":"\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}\n\nfunc (f *functionLog) Usage() (Usage, error) {\n\tresult, err := raw_objects.CallMethod(f, \"usage\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get usage: %w\", err)\n\t}\n\n\tusage, ok := result.(Usage)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for usage: %T\", result)\n\t}\n\n\treturn usage, nil\n}","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_function_log.go#L59-L95","documentation":"Returned by Timing() when the 'timing' call succeeded but the value failed the `result.(Timing)` assertion — the runtime returned a Go value that is not the Timing interface/struct the client expects. This is a client-runtime FFI contract guard: the decoded object is of an unexpected concrete type, pointing to version skew, a decoder bug, or a corrupted object rather than anything the caller did wrong.","triggerScenarios":"timing decodes into a different raw object class (e.g. a plain map/class instead of the Timing raw object); mismatched client and runtime versions; stale functionLog objects.","commonSituations":"Partial upgrade where the BAML engine emits a new timing representation but the Go client predates it; reusing logs post-stream; internal decode errors producing the wrong object variant.","solutions":["Regenerate the Go client so its cffi bindings match the BAML runtime version.","Check the %T in the message to see the actual returned type.","Only consume the FunctionLog while its stream/request is still alive.","Report upstream with versions and the printed type if reproducible on a fresh object."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if fnLog == nil {\n    return errors.New(\"function log is nil; cannot read Timing\")\n}","typeGuard":"func timingIsTiming(v any) bool {\n    _, ok := v.(Timing)\n    return ok\n}","tryCatchPattern":"timing, err := fnLog.Timing()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type for timing:\") {\n        return nil, fmt.Errorf(\"timing object contract mismatch (version skew?): %w\", err)\n    }\n    return nil, err\n}","preventionTips":["Regenerate the client whenever the BAML runtime changes its object representations.","Log the %T type from the error when diagnosing.","Read Timing() during the function stream's lifetime.","Pin client and runtime versions together."],"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"}