{"record":{"id":"56d2fc5b57662ee1","repo":"BoundaryML/baml","slug":"failed-to-get-text-w-rawobjects-sse-response","errorCode":null,"errorMessage":"failed to get text: %w","messagePattern":"failed to get text: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_sse_response.go","lineNumber":30,"sourceCode":"\t*raw_objects.RawObject\n}\n\nfunc newSSEResponse(ptr int64, rt unsafe.Pointer) SSEResponse {\n\treturn &sseResponse{raw_objects.FromPointer(ptr, rt)}\n}\n\nfunc (s *sseResponse) ObjectType() cffi.BamlObjectType {\n\treturn cffi.BamlObjectType_OBJECT_SSE_RESPONSE\n}\n\nfunc (s *sseResponse) pointer() int64 {\n\treturn s.RawObject.Pointer()\n}\n\nfunc (s *sseResponse) Text() (string, error) {\n\tresult, err := raw_objects.CallMethod(s, \"text\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get text: %w\", err)\n\t}\n\n\ttext, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for text: %T\", result)\n\t}\n\n\treturn text, nil\n}\n\nfunc (s *sseResponse) JSON() (any, error) {\n\tresult, err := raw_objects.CallMethod(s, \"json\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get JSON: %w\", err)\n\t}\n\n\treturn result, nil\n}","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_sse_response.go#L12-L48","documentation":"This error wraps any failure from the FFI call to the runtime's `text` method on an SSE response object. Text() retrieves the streamed text payload from the native runtime; if that remote call fails, the cause is preserved via %w. It is a transport/FFI-level failure, not a content problem.","triggerScenarios":"Calling Text() on an SseResponse whose raw object handle is stale or freed, or whose runtime-side `text` method errors while extracting the streamed payload.","commonSituations":"Accessing the SSE response after the stream finished and the object was released; client/runtime version skew; interrupted stream leaving the runtime object in a bad state.","solutions":["Inspect errors.Unwrap(err) for the underlying FFI cause","Consume the SSE response promptly within the stream's lifetime; do not cache handles across requests","Re-run the BAML streaming call to obtain a fresh response object","Align the Go module and native runtime versions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if sseResp == nil { return fmt.Errorf(\"sse response is nil\") }","typeGuard":null,"tryCatchPattern":"text, err := sseResp.Text()\nif err != nil {\n    log.Printf(\"sse text unavailable: %v (cause: %v)\", err, errors.Unwrap(err))\n    return restartStream(ctx)\n}","preventionTips":["Read Text() during the stream's lifetime, not after release","Retry the streaming call on transient FFI failures","Keep Go module and native runtime versions matched"],"tags":["go","ffi","baml","streaming","sse"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}