{"record":{"id":"e21ea38756502739","repo":"BoundaryML/baml","slug":"failed-to-call-object-method-function","errorCode":null,"errorMessage":"failed to call object method function","messagePattern":"failed to call object method function","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/raw_objects/utils.go","lineNumber":179,"sourceCode":"\n\targs := cffi.BamlObjectMethodInvocation{\n\t\tKwargs:     cffi_kwargs,\n\t\tObject:     EncodeRawObject(object),\n\t\tMethodName: method_name,\n\t}\n\n\tencodedArgs, err := proto.Marshal(&args)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal object method arguments: %w\", err)\n\t}\n\tcEncodedArgs := (*C.char)(unsafe.Pointer(&encodedArgs[0]))\n\n\tcBuf := C.WrapCallObjectMethodFunction(object.Runtime(), cEncodedArgs, C.uintptr_t(len(encodedArgs)))\n\n\tcontent_bytes := C.GoBytes(unsafe.Pointer(cBuf.ptr), C.int32_t(cBuf.len))\n\tC.WrapFreeBuffer(cBuf) // Free the buffer after use\n\tif cBuf.len == 0 {\n\t\treturn nil, fmt.Errorf(\"failed to call object method function\")\n\t}\n\tif cBuf.ptr == nil {\n\t\treturn nil, fmt.Errorf(\"object method function returned nil pointer\")\n\t}\n\n\tvar content_holder cffi.InvocationResponse\n\terr = proto.Unmarshal(content_bytes, &content_holder)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal content bytes: %w\", err)\n\t}\n\n\tparsed, err := decodeObjectResponse(object.Runtime(), &content_holder)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode object response: %w\", err)\n\t}\n\n\treturn parsed, nil\n}","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/raw_objects/utils.go#L161-L197","documentation":"This error means the C FFI function WrapCallObjectMethodFunction returned a zero-length buffer, so no InvocationResponse bytes exist. It indicates the native method invocation produced no response at all — the call never completed on the native side.","triggerScenarios":"Calling any BAML object method (destructor, Type, ListProperties, AddProperty, Property, SetType) when the native runtime fails to produce a response buffer, e.g. runtime already destroyed or a native panic.","commonSituations":"Using a builder/object whose runtime was torn down; calling methods after a previous native-side panic; FFI bridge version mismatch.","solutions":["Check FFI logs (BAML_FFI_CLIENT_LOG) for native-side panics preceding this error","Ensure the baml.Runtime outlives all objects created from it","Recreate the object/builder and retry the call","Verify Go bindings and native library versions match"],"exampleFix":"// before: using a type builder after runtime teardown\n// after: hold runtime reference and build/finish within its lifetime\nrt := b.NewRuntime(); defer keepAlive(rt)\ntb := b.NewTypeBuilder(rt); _ = tb.AddProperty(...)","handlingStrategy":"retry","validationCode":"if rt == nil || !runtimeAlive(rt) { return fmt.Errorf(\"baml runtime not available for object method call\") }","typeGuard":null,"tryCatchPattern":"res, err := builder.Type()\nif err != nil && strings.Contains(err.Error(), \"failed to call object method function\") {\n    return fmt.Errorf(\"native call produced no response (runtime alive?): %w\", err)\n}","preventionTips":["Keep the runtime alive for the lifetime of all objects","Check FFI logs for preceding native panics","Recreate the object if its runtime was torn down"],"tags":["go","ffi","native","invocation"],"backgroundTag":"http-request-failed","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"}