BoundaryML/baml · critical
unexpected cffi.isCFFIFieldTypeLiteral_Literal: %#v
Error message
unexpected cffi.isCFFIFieldTypeLiteral_Literal: %#v
What it means
When a CFFI field type is a literal, the decoder only recognizes Bool, Int, and String literals; any other literal variant hits the default branch and panics with the offending value dumped via %#v. This means the runtime emitted a literal field type the compiled Go bindings do not know.
Source
Thrown at engine/language_client_go/baml_go/serde/decode.go:361
if _, ok := type_.(*cffi.CFFIFieldTypeHolder_IntType); ok {
return reflect.TypeOf(int64(0))
}
if _, ok := type_.(*cffi.CFFIFieldTypeHolder_FloatType); ok {
return reflect.TypeOf(float64(0))
}
if literal, ok := type_.(*cffi.CFFIFieldTypeHolder_LiteralType); ok {
literalType := literal.LiteralType
switch literalType.Literal.(type) {
case *cffi.CFFIFieldTypeLiteral_BoolLiteral:
return reflect.TypeOf(false)
case *cffi.CFFIFieldTypeLiteral_IntLiteral:
return reflect.TypeOf(int64(0))
case *cffi.CFFIFieldTypeLiteral_StringLiteral:
return reflect.TypeOf("")
default:
panic(fmt.Sprintf("unexpected cffi.isCFFIFieldTypeLiteral_Literal: %#v", literalType.Literal))
}
}
if class, ok := type_.(*cffi.CFFIFieldTypeHolder_ClassType); ok {
name := class.ClassType.Name.Name
goType, ok := typeMap.GetType(class.ClassType.Name)
if !ok {
// going to be a dynamic class
return reflect.TypeOf(DynamicClass{
Name: name,
})
}
return goType
}
if enum, ok := type_.(*cffi.CFFIFieldTypeHolder_EnumType); ok {
name := enum.EnumType.Name
namespace := cffi.CFFITypeNamespace_TYPES.String()View on GitHub (pinned to bd85ce9dee)
Solutions
- Upgrade baml_go bindings and regenerate baml_client so both support the literal type
- Rebuild the Go binary after upgrading
- Temporarily replace the unsupported literal in the .baml schema with a plain type
- Report the %#v payload to BAML maintainers if versions already match
Example fix
// before (schema using unsupported literal on old client) type Foo string // after: upgrade bindings, then // baml-cli generate && go build ./...
Defensive patterns
Strategy: type-guard
Type guard
func knownLiteral(l cffi.IsCFFIFieldTypeLiteral_Literal) bool {
switch l.(type) { case *cffi.CFFIFieldTypeLiteral_BoolLiteral, *cffi.CFFIFieldTypeLiteral_IntLiteral, *cffi.CFFIFieldTypeLiteral_StringLiteral: return true }
return false
} Try / catch
defer func() { if r := recover(); r != nil { return fmt.Errorf("unsupported literal type: %v", r) } }() Prevention
- Keep baml_go bindings at the same version as the BAML CLI that generated the client
- Avoid new literal-type schema features until bindings support them
- Add recover() around serde conversion of schema-derived types
When it happens
Trigger: convertFieldTypeToGoType encounters a CFFIFieldTypeLiteral whose Literal variant is new or unexpected relative to the compiled bindings — typically after a runtime upgrade introduced a new literal kind (e.g. float literals).
Common situations: BAML runtime updated ahead of Go bindings; using a schema feature (new literal type) unsupported by the installed client version.
Related errors
- Invalid type value
- unexpected stream state
- error decoding value
- invalid media type: '%s'
- undefined enum: {enum_name}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/b8b46950273d7acb.
Report an issue: GitHub.