{"record":{"id":"e873c77b4175327f","repo":"BoundaryML/baml","slug":"unexpected-type-for-sse-chunks-t","errorCode":null,"errorMessage":"unexpected type for SSE chunks: %T","messagePattern":"unexpected type for SSE chunks: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_llm_stream_call.go","lineNumber":31,"sourceCode":"}\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":13,"sourceCodeEnd":41,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_llm_stream_call.go#L13-L41","documentation":"SSEChunks() expects the runtime to return []raw_objects.RawPointer, each castable to SSEResponse. If the top-level result is not a RawPointer slice (e.g. nil or another container), it fails with \"unexpected type for SSE chunks: %T\". Note the per-element chunk.(SSEResponse) later in the function can also panic on element type mismatch.","triggerScenarios":"Calling SSEChunks() when the runtime returns nil (no chunks recorded, e.g. stream never started or failed early) or a differently shaped collection due to version skew.","commonSituations":"Inspecting a stream call that errored before producing any SSE events; generated client built against an older runtime with a different chunk serialization.","solutions":["Only call SSEChunks() after a successful, completed stream","Treat \"unexpected type\" as empty-chunk-set and fall back to stream error info","Update generated client and runtime together"],"exampleFix":"// before\nchunks, err := streamCall.SSEChunks()\n// after\nchunks, err := streamCall.SSEChunks()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type\") {\n        chunks = nil // stream produced no SSE chunks\n    } else {\n        return err\n    }\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Go\nchunks, err := streamCall.SSEChunks()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type\") {\n        chunks = nil // treat as empty chunk set\n    } else {\n        return err\n    }\n}","tryCatchPattern":"// Go: fall back to empty chunks on shape mismatch\nif err != nil && strings.Contains(err.Error(), \"unexpected type for SSE chunks\") {\n    chunks = nil\n}","preventionTips":["Only call SSEChunks() after a stream completed successfully","Treat empty/nil chunk results as legitimate for failed streams","Upgrade client and runtime together"],"tags":["go","ffi","streaming","type-mismatch"],"backgroundTag":"type-mismatch","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"}