BoundaryML/baml · error
error decoding type, checked type not found:
Error message
error decoding type, checked type not found:
What it means
When decoding a type descriptor received over the Go/C++ FFI boundary, baml's Go serde encounters a CheckedType (a BAML `check` expression result type). It serializes the inner type to a name via typeToString and looks it up in the caller-provided TypeMap under the "CHECKED_TYPES." prefix. This panic means the generated TypeMap shipped with the generated Go code has no entry for that checked type, so decoding cannot proceed and it fails fast with a panic.
Source
Thrown at engine/language_client_go/baml_go/serde/decode.go:426
}
if optional, ok := type_.(*cffi.CFFIFieldTypeHolder_OptionalType); ok {
optionalType := optional.OptionalType
goType := convertFieldTypeToGoType(optionalType.Value, typeMap)
if goType == typeMap.typeMap["INTERNAL.nil"] {
// Pointer to nil / any is same as nil / any
return goType
}
return reflect.PointerTo(goType)
}
if checked, ok := type_.(*cffi.CFFIFieldTypeHolder_CheckedType); ok {
checkedType := checked.CheckedType
serializeType := typeToString(checkedType.Value)
goType, ok := typeMap.typeMap["CHECKED_TYPES."+serializeType]
if !ok {
panic("error decoding type, checked type not found: " + serializeType + ", typeMap=" + fmt.Sprintf("%+v", typeMap))
}
return goType
}
if streamState, ok := type_.(*cffi.CFFIFieldTypeHolder_StreamStateType); ok {
streamStateType := streamState.StreamStateType
return convertFieldTypeToGoType(streamStateType.Value, typeMap)
}
if list, ok := type_.(*cffi.CFFIFieldTypeHolder_ListType); ok {
listType := list.ListType
goElementType := convertFieldTypeToGoType(listType.ItemType, typeMap)
if goElementType == typeMap.typeMap["INTERNAL.nil"] {
return reflect.TypeOf([]any{})
}
return reflect.SliceOf(goElementType)
}
View on GitHub (pinned to bd85ce9dee)
Solutions
- Regenerate the Go client with `baml-cli generate` (or `baml generate`) so the TypeMap includes the new checked type
- Update the baml-cli and baml_go runtime packages to matching versions (go get -u github.com/boundaryml/baml/...) so serialization names align
- If the check is new in the .baml file, confirm the generated baml_go client directory is actually the one being imported (stale module cache / replace directive)
- As a last resort, remove or rename the check expression in the .baml file to a supported output shape and regenerate
Example fix
// before: stale generated code missing the check entry, decode panics client, _ := baml.NewGoClient(ctx, baml.LoadCollector()) // old generated TypeMap baml.ExtractResume(ctx, client, text) // panic: checked type not found // after: regenerate then run cd b/baml_src && baml-cli generate # refresh generated TypeMap with CHECKED_TYPES entries baml.ExtractResume(ctx, client, text)
Defensive patterns
Strategy: validation
Validate before calling
// Regeneration check: ensure generated TypeMap contains CHECKED_TYPES entries
func validateCheckedTypes(tm baml_go.TypeMap) error {
for name := range requiredCheckedTypesFromBamlSrc() {
if _, ok := tm.TypeMap["CHECKED_TYPES."+name]; !ok {
return fmt.Errorf("missing generated checked type %q — run baml-cli generate", name)
}
}
return nil
} Prevention
- Always run baml-cli generate after editing .baml files before building the Go app
- Add a CI step diffing generated client code against the committed copy
- Keep baml-cli and the Go baml dependency on the same released version
When it happens
Trigger: Calling a BAML function whose output (or a nested field) contains a check (e.g. `check ... expr`), while the Go TypeMap built by baml-cli generate lacks a "CHECKED_TYPES.<serialized-type>" key — typically because the generated client code is stale relative to the baml file or the TypeMap was constructed without checked-type entries.
Common situations: Editing a .baml file to add or change a check() expression and re-running the app without regenerating the Go client; version mismatch between the baml CLI that produced cffi payloads and the generated Go code; hand-built TypeMaps used in tests that omit CHECKED_TYPES entries.
Related errors
- error decoding value, type alias not found:
- error decoding value, unknown field type:
- error decoding value, unknown literal type:
- ObjectValue is not yet supported:
- error decoding value:
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/d5891aa7342f0c99.
Report an issue: GitHub.