{"record":{"id":"d5891aa7342f0c99","repo":"BoundaryML/baml","slug":"error-decoding-type-checked-type-not-found","errorCode":null,"errorMessage":"error decoding type, checked type not found: ","messagePattern":"error decoding type, checked type not found: ","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/serde/decode.go","lineNumber":426,"sourceCode":"\n\t}\n\n\tif optional, ok := type_.(*cffi.CFFIFieldTypeHolder_OptionalType); ok {\n\t\toptionalType := optional.OptionalType\n\t\tgoType := convertFieldTypeToGoType(optionalType.Value, typeMap)\n\t\tif goType == typeMap.typeMap[\"INTERNAL.nil\"] {\n\t\t\t// Pointer to nil / any is same as nil / any\n\t\t\treturn goType\n\t\t}\n\t\treturn reflect.PointerTo(goType)\n\t}\n\n\tif checked, ok := type_.(*cffi.CFFIFieldTypeHolder_CheckedType); ok {\n\t\tcheckedType := checked.CheckedType\n\t\tserializeType := typeToString(checkedType.Value)\n\t\tgoType, ok := typeMap.typeMap[\"CHECKED_TYPES.\"+serializeType]\n\t\tif !ok {\n\t\t\tpanic(\"error decoding type, checked type not found: \" + serializeType + \", typeMap=\" + fmt.Sprintf(\"%+v\", typeMap))\n\t\t}\n\t\treturn goType\n\t}\n\n\tif streamState, ok := type_.(*cffi.CFFIFieldTypeHolder_StreamStateType); ok {\n\t\tstreamStateType := streamState.StreamStateType\n\t\treturn convertFieldTypeToGoType(streamStateType.Value, typeMap)\n\t}\n\n\tif list, ok := type_.(*cffi.CFFIFieldTypeHolder_ListType); ok {\n\t\tlistType := list.ListType\n\t\tgoElementType := convertFieldTypeToGoType(listType.ItemType, typeMap)\n\t\tif goElementType == typeMap.typeMap[\"INTERNAL.nil\"] {\n\t\t\treturn reflect.TypeOf([]any{})\n\t\t}\n\t\treturn reflect.SliceOf(goElementType)\n\t}\n","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/serde/decode.go#L408-L444","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: stale generated code missing the check entry, decode panics\nclient, _ := baml.NewGoClient(ctx, baml.LoadCollector()) // old generated TypeMap\nbaml.ExtractResume(ctx, client, text) // panic: checked type not found\n\n// after: regenerate then run\ncd b/baml_src && baml-cli generate  # refresh generated TypeMap with CHECKED_TYPES entries\nbaml.ExtractResume(ctx, client, text)","handlingStrategy":"validation","validationCode":"// Regeneration check: ensure generated TypeMap contains CHECKED_TYPES entries\nfunc validateCheckedTypes(tm baml_go.TypeMap) error {\n\tfor name := range requiredCheckedTypesFromBamlSrc() {\n\t\tif _, ok := tm.TypeMap[\"CHECKED_TYPES.\"+name]; !ok {\n\t\t\treturn fmt.Errorf(\"missing generated checked type %q — run baml-cli generate\", name)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["go","ffi","deserialization","baml","codegen"],"backgroundTag":"unexpected-response-shape","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}