BoundaryML/baml · critical
error decoding value, checked type not found:
Error message
error decoding value, checked type not found:
What it means
After decoding a checked value's payload and checks, the decoder looks up the checked type's Go type by name in the supplied TypeMap. If the name is absent, it panics, because it cannot construct the target struct holding Value and Checks fields. This means the TypeMap generated from the BAML schema does not know this checked type.
Solutions
- Run `baml-cli generate` (or your build step) to regenerate baml_client after schema changes
- Ensure the Go binary is rebuilt after regeneration so the new TypeMap is compiled in
- Verify check/assert names in the .baml schema match those the client was generated with
- Align baml_go bindings and BAML runtime versions
Example fix
// before (stale generated client after adding a check) // after // terminal: baml-cli generate && go build ./...
Defensive patterns
Strategy: validation
Validate before calling
if _, ok := typeMap.GetType(checkedName); !ok { return fmt.Errorf("type %v missing; regenerate client", checkedName) } Try / catch
defer func() { if r := recover(); r != nil { return fmt.Errorf("checked type not in typemap: %v", r) } }() Prevention
- Run baml-cli generate in CI whenever .baml files change
- Rebuild the Go binary after regeneration
- Never run a stale compiled client against an edited schema
When it happens
Trigger: Decode() on a CFFIValueChecked whose Name is not registered in typeMap — typically when generated client types are stale relative to the BAML schema (a check/assert type was added or renamed).
Common situations: Editing a BAML file to add a new check without regenerating baml_client; switching branches where the schema changed; running an older compiled client against a newer .baml schema.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- decodeCheckedValue: valueChecked is nil
- decodeUnionValue: valueUnion is nil
- error decoding value
- internal error: attempted to register unknown function
- invalid media type
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/4ff6b6edc3de76c2.
Report an issue: GitHub.
Appendix: source
Thrown at engine/language_client_go/baml_go/serde/decode.go:307
func decodeCheckedValue(valueChecked *cffi.CFFIValueChecked, typeMap TypeMap) (reflect.Value, reflect.Type) {
if valueChecked == nil {
panic("decodeCheckedValue: valueChecked is nil")
}
value := valueChecked.Value
decodedValue, _ := Decode(value, typeMap)
checks := make(map[string]shared.Check, len(valueChecked.Checks))
for _, check := range valueChecked.Checks {
checks[string(check.Name)] = shared.Check{
Name: string(check.Name),
Expression: string(check.Expression),
Status: string(check.Status),
}
}
goType, ok := typeMap.GetType(valueChecked.Name)
if !ok {
panic("error decoding value, checked type not found: " + valueChecked.Name.String())
}
checkedValue := reflect.New(goType)
checkedValue.Elem().FieldByName("Value").Set(decodedValue)
checkedValue.Elem().FieldByName("Checks").Set(reflect.ValueOf(checks))
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")
}View on GitHub (pinned to bd85ce9dee)