{"record":{"id":"a632816b31d5f3cc","repo":"BoundaryML/baml","slug":"unsupported-type-streamstate-any-cannot-be-passed-as-inputs","errorCode":null,"errorMessage":"unsupported type: StreamState[any] cannot be passed as inputs to baml functions","messagePattern":"unsupported type: StreamState\\[any\\] cannot be passed as inputs to baml functions","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/serde/encode.go","lineNumber":129,"sourceCode":"\t\t\t\tHandle: handle,\n\t\t\t},\n\t\t}, nil\n\t}\n\n\t// Check for custom serializers first using the original value (could be pointer or value)\n\tif serializer, ok := originalValue.(BamlSerializer); ok {\n\t\tencoded, err := serializer.Encode()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn encoded, nil\n\t}\n\n\tswitch concreteValue.(type) {\n\tcase shared.Checked[any]:\n\t\treturn nil, fmt.Errorf(\"unsupported type: Checked[any] cannot be passed as inputs to baml functions\")\n\tcase shared.StreamState[any]:\n\t\treturn nil, fmt.Errorf(\"unsupported type: StreamState[any] cannot be passed as inputs to baml functions\")\n\t}\n\n\t// Handle primitive kinds and collections using reflection value rv (points to underlying value)\n\tswitch rv.Kind() {\n\tcase reflect.String:\n\t\treturn &cffi.HostValue{\n\t\t\tValue: &cffi.HostValue_StringValue{\n\t\t\t\tStringValue: rv.String(),\n\t\t\t},\n\t\t}, nil\n\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn &cffi.HostValue{\n\t\t\tValue: &cffi.HostValue_IntValue{\n\t\t\t\tIntValue: rv.Int(),\n\t\t\t},\n\t\t}, nil\n","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/serde/encode.go#L111-L147","documentation":"shared.StreamState[any] is an internal streaming bookkeeping type produced by baml streaming calls; it is not a serializable input. encodeValue explicitly rejects it when it appears among baml function arguments.","triggerScenarios":"Passing the StreamState returned by a streaming baml call (or an object/field containing it) as an argument to another baml function; storing a streaming state inside a class field passed to baml.","commonSituations":"Chaining streaming calls; accidentally using the StreamState container instead of its current value; holding stream state in a shared struct that is later reused as input.","solutions":["Extract the actual streamed value from the StreamState before passing it on","Pass the concrete data (string/struct/slice) rather than the stream container","Keep streaming state out of structs used as baml inputs"],"exampleFix":"// before\nstate := stream.State // shared.StreamState[any]\nb.Next(ctx, state)\n// after\nb.Next(ctx, state.Value)","handlingStrategy":"type-guard","validationCode":"func notStreamState(v any) bool { return !strings.Contains(reflect.TypeOf(v).String(), \"StreamState\") }","typeGuard":"func isStreamState(v any) bool { return strings.Contains(reflect.TypeOf(v).String(), \"StreamState\") }","tryCatchPattern":"if err := b.Fn(ctx, in); err != nil {\n  if strings.Contains(err.Error(), \"StreamState[any] cannot be passed\") { /* extract .Value and retry */ }\n}","preventionTips":["Extract the current value from StreamState before forwarding data between calls","Never store StreamState inside structs used as baml inputs","Keep streaming bookkeeping separate from payload data"],"tags":["go","baml","streaming","type-restriction"],"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"}