BoundaryML/baml · critical
error decoding value
Error message
error decoding value
What it means
convertFieldTypeToGoType panics when the *cffi.CFFIFieldTypeHolder is nil. Field type metadata is required to map a CFFI field to a Go reflect.Type (used by lists, maps, unions, and recursive type conversion); nil means the runtime supplied incomplete type information.
Source
Thrown at engine/language_client_go/baml_go/serde/decode.go:330
return checkedValue.Elem(), goType
}
func decodeStreamStateType(state cffi.CFFIStreamState) shared.StreamStateType {
switch state {
case cffi.CFFIStreamState_PENDING:
return shared.StreamStatePending
case cffi.CFFIStreamState_STARTED:
return shared.StreamStateIncomplete
case cffi.CFFIStreamState_DONE:
return shared.StreamStateComplete
default:
panic("unexpected stream state")
}
}
func convertFieldTypeToGoType(fieldType *cffi.CFFIFieldTypeHolder, typeMap TypeMap) reflect.Type {
if fieldType == nil {
panic("error decoding value")
}
type_ := fieldType.Type
if _, ok := type_.(*cffi.CFFIFieldTypeHolder_StringType); ok {
return reflect.TypeOf("")
}
if _, ok := type_.(*cffi.CFFIFieldTypeHolder_BoolType); ok {
return reflect.TypeOf(false)
}
if _, ok := type_.(*cffi.CFFIFieldTypeHolder_IntType); ok {
return reflect.TypeOf(int64(0))
}
if _, ok := type_.(*cffi.CFFIFieldTypeHolder_FloatType); ok {
return reflect.TypeOf(float64(0))View on GitHub (pinned to bd85ce9dee)
Solutions
- Regenerate baml_client and rebuild so type metadata matches the runtime
- Upgrade baml_go bindings to the version matching your BAML CLI
- Check the .baml schema for exotic types and simplify if on an old version
- File a bug with the schema and payload that produced nil field metadata
Defensive patterns
Strategy: type-guard
Validate before calling
if fieldType == nil { return reflect.TypeOf(nil) } Type guard
func hasFieldType(h *cffi.CFFIFieldTypeHolder) bool { return h != nil && h.Type != nil } Try / catch
defer func() { if r := recover(); r != nil { log.Printf("field type decode failed: %v", r) } }() Prevention
- Nil-check field metadata before decoding lists/maps/unions
- Regenerate the client after runtime upgrades
- Report schemas that produce nil field metadata to maintainers
When it happens
Trigger: decodeListValue, decodeMapValue, decodeUnionValue, or a recursive convertFieldTypeToGoType call receives a nil field-type holder from the CFFI payload.
Common situations: Runtime/generator version mismatch where field metadata is dropped, corrupted native responses, or BAML schema constructs the installed bindings cannot describe.
Related errors
- decodeUnionValue: valueUnion is nil
- decodeCheckedValue: valueChecked is nil
- unexpected cffi.isCFFIFieldTypeLiteral_Literal: %#v
- field access must be on classes, but expr `{}` got: {other:?
- Invalid type value
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/b0d32613c2863dec.
Report an issue: GitHub.