{"record":{"id":"322885b9a6c2a273","repo":"BoundaryML/baml","slug":"unexpected-type-for-enum-value-builder-t","errorCode":null,"errorMessage":"unexpected type for enum value builder: %T","messagePattern":"unexpected type for enum value builder: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_enum_builder.go","lineNumber":39,"sourceCode":"func newEnumBuilder(ptr int64, rt unsafe.Pointer) EnumBuilder {\n\tbldr := enumBuilder{raw_objects.FromPointer(ptr, rt), llmRenderableObject{}}\n\tbldr.llmRenderableObject = llmRenderableObject{&bldr}\n\treturn &bldr\n}\n\n// AddValue adds a new value to the enum\nfunc (eb *enumBuilder) AddValue(value string) (EnumValueBuilder, error) {\n\targs := map[string]interface{}{\n\t\t\"value\": value,\n\t}\n\tresult, err := raw_objects.CallMethod(eb, \"add_value\", args)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tenumValueBuilder, ok := result.(EnumValueBuilder)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for enum value builder: %T\", result)\n\t}\n\n\treturn enumValueBuilder, nil\n}\n\n// Type returns the type definition for this enum\nfunc (eb *enumBuilder) Type() (Type, error) {\n\tresult, err := raw_objects.CallMethod(eb, \"type_\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttyp, ok := result.(Type)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for enum type: %T\", result)\n\t}\n\n\treturn typ, nil","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_enum_builder.go#L21-L57","documentation":"EnumBuilder.AddValue delegates to an internal helper that creates the enum value builder, then asserts the returned value implements EnumValueBuilder. If it does not, this error is thrown. It indicates the runtime's generic object factory returned an unexpected wrapper type when adding a value to a dynamic enum.","triggerScenarios":"Calling AddValue on a runtime-constructed enum builder when the internal creation call returns a non-EnumValueBuilder result — a bindings/runtime version mismatch or a dispatch bug in the raw object factory.","commonSituations":"Mixed Go SDK / native runtime versions after partial upgrade; custom engine builds; hitting it in tests like TestTypeBuilderSkipEnumValue signals broken bindings rather than test input issues.","solutions":["Align the Go SDK module and native BAML runtime to one consistent version (`go mod tidy`, reinstall)","Rebuild or re-download the native runtime binary","Read the %T value in the message to identify the wrong type returned and report upstream if reproducible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func asEnumValueBuilder(v any) (EnumValueBuilder, bool) {\n    evb, ok := v.(EnumValueBuilder)\n    return evb, ok\n}","tryCatchPattern":"evb, err := enumBuilder.AddValue(\"ACTIVE\")\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type for enum value builder\") {\n        return nil, fmt.Errorf(\"baml bindings/runtime version mismatch: %w\", err)\n    }\n    return nil, err\n}","preventionTips":["Keep the baml Go module and native runtime from the same release","Exercise enum/type-builder paths in a startup smoke test to catch binding drift early","When reporting, include the %T value from the error message"],"tags":["go","baml-runtime","type-assertion","enum","internal"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}