{"record":{"id":"6006f4498465c70a","repo":"BoundaryML/baml","slug":"failed-to-get-raw-llm-response-w","errorCode":null,"errorMessage":"failed to get raw LLM response: %w","messagePattern":"failed to get raw LLM response: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_function_log.go","lineNumber":100,"sourceCode":"\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}\n\nfunc (f *functionLog) RawLLMResponse() (string, error) {\n\tresult, err := raw_objects.CallMethod(f, \"raw_llm_response\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get raw LLM response: %w\", err)\n\t}\n\n\tresponse, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for raw LLM response: %T\", result)\n\t}\n\n\treturn response, nil\n}\n\nfunc (f *functionLog) CallsCount() (int, error) {\n\tresult, err := raw_objects.CallMethod(f, \"calls_count\", nil)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to get calls count: %w\", err)\n\t}\n\n\tcount, ok := result.(int)\n\tif !ok {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_function_log.go#L82-L118","documentation":"This error wraps any failure from raw_objects.CallMethod when RawLLMResponse() fetches the 'raw_llm_response' attribute of a FunctionLog via the C FFI. It is a pass-through wrapper: the actionable cause (empty FFI response buffer, nil pointer, proto unmarshal failure, or object-response decode failure) lives in the wrapped error. It means the Go client could not retrieve the raw LLM response text from the runtime object.","triggerScenarios":"Calling RawLLMResponse() on a functionLog whose runtime object was freed or is invalid; the FFI method call returned an empty buffer or nil pointer; the protobuf response failed to unmarshal/decode.","commonSituations":"Reading raw responses after a stream completed and objects were reclaimed; caching log references in long-running services; Go client vs BAML runtime version mismatch.","solutions":["Unwrap the error (errors.Unwrap / %w chain) to see the concrete FFI failure ('failed to call object method function', 'nil pointer', decode failure).","Read RawLLMResponse() within the lifetime of the owning function call/stream.","Keep the generated Go client in sync with the BAML runtime (re-run `baml generate`).","If the wrapped error is an unmarshal/decode failure on a live object, report it upstream with your versions."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if fnLog == nil {\n    return errors.New(\"function log is nil; cannot read RawLLMResponse\")\n}","typeGuard":"func isCallMethodFailure(err error) bool {\n    return strings.Contains(err.Error(), \"failed to call object method\")\n}","tryCatchPattern":"raw, err := fnLog.RawLLMResponse()\nif err != nil {\n    log.Printf(\"RawLLMResponse unavailable: %v (wrapped: %v)\", err, errors.Unwrap(err))\n    return fmt.Errorf(\"baml raw LLM response inaccessible: %w\", err)\n}","preventionTips":["Unwrap this error to reach the concrete FFI cause.","Fetch the raw response before the function stream completes.","Regenerate the client after any BAML runtime upgrade.","Do not cache functionLog references beyond the request scope."],"tags":["go","ffi","wrapped-error","baml"],"backgroundTag":"unexpected-response-shape","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"}