SiennaRed
01/17/2026, 2:29 AMDecode() methods for classes marked with @@dynamic. The generated code initializes DynamicProperties but never populates it with the parsed field values, resulting in all dynamic fields being lost during deserialization.
The generated Decode() method only initializes the map but never iterates through fields:
go
func (c *Response) Decode(holder *cffi.CFFIValueClass, typeMap baml.TypeMap) {
typeName := holder.Name
if typeName.Namespace != cffi.CFFITypeNamespace_TYPES {
panic(...)
}
if typeName.Name != "Response" {
panic(...)
}
c.DynamicProperties = make(map[string]any)
// BUG: Missing loop to iterate through holder.Fields!
}
Looking at BAML's own test files (engine/generators/languages/go/generated_tests/dynamic_types/baml_client/types/classes.go), classes with both static and dynamic properties correctly implement the field iteration:
go
switch key {
case "title":
....
default:
c.DynamicProperties[key] = baml.DecodeToValue(valueHolder)
}
This suggests the template conditionally generates the loop only when there are static fields to switch on, but forgets to handle the pure-dynamic case.
we have a workaround for now by adding a dummy static field bamlVersion int? to the Response class in baml_src: class Response {
bamlVersion int? // Workaround for BAML Go codegen bug
@@dynamic
}Vaibhav (BAML 🐑)
01/17/2026, 3:08 AMVaibhav (BAML 🐑)
01/17/2026, 3:08 AMVaibhav (BAML 🐑)
01/17/2026, 4:30 AMinvakid404
01/19/2026, 3:44 PMaaronv (BAML)
01/22/2026, 8:57 AM