{"record":{"id":"bcadf8263e1a4da2","repo":"BoundaryML/baml","slug":"error-decoding-value-decode","errorCode":null,"errorMessage":"error decoding value: ","messagePattern":"error decoding value: ","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/serde/decode.go","lineNumber":595,"sourceCode":"\t\treturn decodeClassValue(value.ClassValue, typeMap)\n\tcase *cffi.CFFIValueHolder_EnumValue:\n\t\treturn decodeEnumValue(value.EnumValue, typeMap)\n\tcase *cffi.CFFIValueHolder_ListValue:\n\t\treturn decodeListValue(value.ListValue, typeMap)\n\tcase *cffi.CFFIValueHolder_MapValue:\n\t\treturn decodeMapValue(value.MapValue, typeMap)\n\tcase *cffi.CFFIValueHolder_UnionVariantValue:\n\t\treturn decodeUnionValue(value.UnionVariantValue, typeMap)\n\tcase *cffi.CFFIValueHolder_CheckedValue:\n\t\treturn decodeCheckedValue(value.CheckedValue, typeMap)\n\tcase *cffi.CFFIValueHolder_StreamingStateValue:\n\t\treturn decodeStreamingStateValue(value.StreamingStateValue, typeMap)\n\tcase *cffi.CFFIValueHolder_LiteralValue:\n\t\treturn decodeLiteralValue(value.LiteralValue, typeMap)\n\tcase *cffi.CFFIValueHolder_ObjectValue:\n\t\tpanic(\"ObjectValue is not yet supported: \" + holder.String())\n\tdefault:\n\t\tpanic(\"error decoding value: \" + holder.String())\n\t}\n}\n\nfunc decodeLiteralValue(valueLiteral *cffi.CFFIFieldTypeLiteral, _ TypeMap) (reflect.Value, reflect.Type) {\n\tif valueLiteral == nil {\n\t\tpanic(\"decodeLiteralValue: valueLiteral is nil\")\n\t}\n\n\tswitch value := valueLiteral.Literal.(type) {\n\tcase *cffi.CFFIFieldTypeLiteral_BoolLiteral:\n\t\treturn reflect.ValueOf(value.BoolLiteral.Value), reflect.TypeOf(false)\n\tcase *cffi.CFFIFieldTypeLiteral_IntLiteral:\n\t\treturn reflect.ValueOf(value.IntLiteral.Value), reflect.TypeOf(int64(0))\n\tcase *cffi.CFFIFieldTypeLiteral_StringLiteral:\n\t\treturn reflect.ValueOf(value.StringLiteral.Value), reflect.TypeOf(\"\")\n\tdefault:\n\t\tpanic(\"error decoding value, unknown literal type: \" + fmt.Sprintf(\"%+v\", value))\n\t}","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/serde/decode.go#L577-L613","documentation":"Decode's default branch: the CFFIValueHolder carried a Value variant that the Go serde switch does not recognize at all (not null/string/int/float/bool/class/enum/list/map/union/checked/streaming/literal/object). The Go runtime was compiled against a different CFFI protocol version than the engine, so it panics with the holder dump.","triggerScenarios":"The native baml library emits a value holder variant unknown to the compiled Go client — typical when the engine and Go dependency versions are out of sync, or when a malformed holder reaches Decode from the FFI layer.","commonSituations":"Partial upgrades (CLI updated, Go module not); vendored generated code drifting from the runtime; running against a dev build of the baml engine.","solutions":["Align versions: upgrade the Go baml runtime and regenerate so the Decode switch covers the engine's value variants","Ensure the loaded native baml library matches the Go module version (reinstall the CLI/native lib)","Inspect holder.String() in the panic to identify the unknown variant and cross-check baml release notes","If intentional protocol extension, report/get a Go runtime fix; otherwise pin both sides to the same release"],"exampleFix":"// before: mixed versions -> unknown holder variant panic\n// after:\ngo get github.com/boundaryml/baml@latest\nbaml-cli generate\ngo mod tidy && go build ./...","handlingStrategy":"try-catch","validationCode":"// Fail fast on engine/runtime mismatch at startup\nfunc init() {\n\tif baml.EngineVersion() != baml_go.GeneratedForVersion {\n\t\tpanic(\"baml engine/runtime version mismatch — regenerate the Go client\")\n\t}\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n\tif r := recover(); r != nil {\n\t\tlog.Printf(\"baml decode panic (unknown value holder): %v\", r)\n\t}\n}()","preventionTips":["Always upgrade CLI and Go dependency together; add a version-equality startup check","Avoid dev builds of the engine against released generated clients","Keep generated baml_go code in version control and CI-verified"],"tags":["go","ffi","deserialization","version-mismatch","baml"],"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"}