{"record":{"id":"7d60c16b3ccce85f","repo":"BoundaryML/baml","slug":"failed-to-create-type-builder-w","errorCode":null,"errorMessage":"failed to create type builder: %w","messagePattern":"failed to create type builder: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_constructors.go","lineNumber":112,"sourceCode":"\treturn r.newMediaFromBase64(MediaType_Image, base64, mimeType)\n}\n\nfunc (r *BamlRuntime) NewAudioFromBase64(base64 string, mimeType *string) (Audio, error) {\n\treturn r.newMediaFromBase64(MediaType_Audio, base64, mimeType)\n}\n\nfunc (r *BamlRuntime) NewPDFFromBase64(base64 string, mimeType *string) (PDF, error) {\n\treturn r.newMediaFromBase64(MediaType_PDF, base64, mimeType)\n}\n\nfunc (r *BamlRuntime) NewVideoFromBase64(base64 string, mimeType *string) (Video, error) {\n\treturn r.newMediaFromBase64(MediaType_Video, base64, mimeType)\n}\n\nfunc (r *BamlRuntime) NewTypeBuilder() (TypeBuilder, error) {\n\tptr, err := raw_objects.NewRawObject(r.runtime, cffi.BamlObjectType_OBJECT_TYPE_BUILDER, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create type builder: %w\", err)\n\t}\n\n\tas_type_builder, ok := ptr.(*typeBuilder)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for type builder creation: %T\", ptr)\n\t}\n\n\treturn as_type_builder, nil\n}\n","sourceCodeStart":94,"sourceCodeEnd":122,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_constructors.go#L94-L122","documentation":"NewTypeBuilder asks the Rust runtime to create an OBJECT_TYPE_BUILDER raw object; if the runtime returns an error, it is wrapped as 'failed to create type builder'. The type builder is used for constructing dynamic types at runtime, so this failure blocks all subsequent dynamic-type construction.","triggerScenarios":"Calling NewTypeBuilder() when raw_objects.NewRawObject(OBJECT_TYPE_BUILDER, nil) fails — typically a runtime-level allocation or cffi dispatch failure, or a runtime build that does not support type builders.","commonSituations":"A native runtime binary too old to support object type builders; corrupted or incompatible runtime after upgrade; resource exhaustion in the embedded runtime.","solutions":["Check the wrapped inner error for the runtime's specific failure reason","Verify the native BAML runtime version supports type builders (upgrade if old)","Confirm the runtime loaded correctly (correct binary for platform/arch)","Report upstream with the error chain if it reproduces on a current, clean install"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"tb, err := runtime.NewTypeBuilder()\nif err != nil {\n    return nil, fmt.Errorf(\"type builder unavailable (check runtime version/support): %w\", err)\n}\ndefer tb.Destroy() // or whatever cleanup the API provides","preventionTips":["Verify the native runtime version supports object type builders before using dynamic types","Check runtime initialization logs for load errors before constructing builders","Treat type-builder construction as fallible and always check the error"],"tags":["go","baml-runtime","type-builder","construction-failure"],"backgroundTag":"invalid-argument-value","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}