https://www.boundaryml.com logo
🟡 Go Streaming Decode Panics on @stream.not_null ...
# questions
s
BAML team, seeing this issue. wondering if you are able to reproduce : Any streaming call to a BAML function returning a class with @stream.not_null on a string field.? Go streaming decode panics on @stream.not_null string fields: StreamState[string] not string When a BAML class uses @stream.not_null on a string field (e.g., intent "foo" @stream.not_null), the Go code generator emits stream_types Decode methods that assert .(string): c.Intent = baml.Decode(valueHolder).Interface().(string) But during streaming, the Rust runtime sends these fields as StreamingStateValue protobuf messages, which serde.Decode resolves to shared.StreamState[string]. The type assertion panics: panic: interface conversion: interface {} is shared.StreamState[string], not string This crashes the process since the panic occurs inside a CGO //export callback (trigger_callback).
a
we'll take a look tomorrow!
g
Thanks for the report, @SiennaRed! I'm looking into this and would love to help you debug it. What I've done so far is to create a small BAML file to try to reproduce the issue. It uses a single class with three fields, one of them is @stream.not_null, one is @stream.done and @stream.not_null, the third is a plain string. In this case I can't manage to get your decoding error. The decoding error you see mentions
StreamState
, which should only appear if you use the @stream.with_state annotation. The fact that you see this error message makes me think that there may be a version mismatch between your generated go client and the go BAML runtime. Is it possible to share your BAML code? I'd like to see the generator, its version, and your types. And could you tell me which version of the go baml library you're using?
s
Generator & versions: // baml_src/generators.baml generator target { output_type "go" output_dir "../baml_client" version "0.218.1" default_client_mode "sync" } Go module version (go.mod): github.com/boundaryml/baml v0.218.1 Both are at 0.218.1, no version mismatch. Example BAML types that trigger it: class ClarificationRequest { intent "request_more_information" @stream.not_null message string @stream.with_state } class DoneForNow { intent "done_for_now" @stream.not_null message string @stream.with_state } The panic happens on the intent field during streaming decode. The intent string arrives as StreamState[string] but the generated code asserts .(string).
thanks for looking into this @greg (BAML) . please let me know if you need anything else
g
@SiennaRed I fixed a bug in go codegen that appeared to be related to your problem! After the release of 0.220.0, let's see if your issue is solved.