{"record":{"id":"fa49d5ae643e3d2d","repo":"BoundaryML/baml","slug":"failed-to-get-sse-chunks-w","errorCode":null,"errorMessage":"failed to get SSE chunks: %w","messagePattern":"failed to get SSE chunks: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_llm_stream_call.go","lineNumber":26,"sourceCode":"\t\"github.com/boundaryml/baml/engine/language_client_go/pkg/cffi\"\n)\n\ntype llmStreamCall struct {\n\t*llmCall\n}\n\nfunc newLLMStreamCall(ptr int64, rt unsafe.Pointer) LLMStreamCall {\n\treturn &llmStreamCall{&llmCall{raw_objects.FromPointer(ptr, rt)}}\n}\n\nfunc (l *llmStreamCall) ObjectType() cffi.BamlObjectType {\n\treturn cffi.BamlObjectType_OBJECT_LLM_STREAM_CALL\n}\n\nfunc (l *llmStreamCall) SSEChunks() ([]SSEResponse, error) {\n\tresult, err := raw_objects.CallMethod(l, \"sse_chunks\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get SSE chunks: %w\", err)\n\t}\n\n\tcasted, ok := result.([]raw_objects.RawPointer)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for SSE chunks: %T\", result)\n\t}\n\n\tchunks := make([]SSEResponse, len(casted))\n\tfor i, chunk := range casted {\n\t\tchunks[i] = chunk.(SSEResponse)\n\t}\n\n\treturn chunks, nil\n}\n","sourceCodeStart":8,"sourceCodeEnd":41,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_llm_stream_call.go#L8-L41","documentation":"llmStreamCall.SSEChunks() calls the native \"sse_chunks\" method; any error from that FFI invocation is wrapped as \"failed to get SSE chunks: %w\". It signals the runtime could not return the chunk list for this stream call handle.","triggerScenarios":"Calling SSEChunks() on an llmStreamCall whose native object was invalidated, after stream teardown, or when the runtime errors internally while collecting chunks.","commonSituations":"Reading chunks after the BAML runtime shut down; using a stream call from an aborted/failed stream; native library and generated client version mismatch.","solutions":["Read the wrapped cause to identify the FFI failure","Collect SSEChunks() while the stream/runtime is still alive","Re-run the stream and read chunks from the new stream call","Match generated client and native runtime versions"],"exampleFix":"// before\nchunks, err := streamCall.SSEChunks()\n// after\nchunks, err := streamCall.SSEChunks()\nif err != nil {\n    return fmt.Errorf(\"sse chunks unavailable: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go\nchunks, err := streamCall.SSEChunks()\nif err != nil {\n    return fmt.Errorf(\"sse chunks unavailable: %w\", err)\n}","preventionTips":["Collect chunks while the stream and runtime are alive","Don't inspect stream calls from aborted/errored streams without handling failure","Keep client/runtime versions aligned"],"tags":["go","ffi","streaming"],"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-14T11:17:12.474Z"}