{"record":{"id":"ff66989a459e5964","repo":"BoundaryML/baml","slug":"failed-to-decode-object-response-w","errorCode":null,"errorMessage":"failed to decode object response: %w","messagePattern":"failed to decode object response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/raw_objects/utils.go","lineNumber":137,"sourceCode":"\n\tcontent_bytes := C.GoBytes(unsafe.Pointer(cBuf.ptr), C.int32_t(cBuf.len))\n\tC.WrapFreeBuffer(cBuf) // Free the buffer after use\n\n\tif cBuf.len == 0 {\n\t\treturn nil, fmt.Errorf(\"failed to call object constructor\")\n\t}\n\tif cBuf.ptr == nil {\n\t\treturn nil, fmt.Errorf(\"object constructor 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\tparsed, err := decodeObjectResponse(rt, &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}\n\nfunc destructor(object RawPointer) error {\n\tresult, err := CallMethod(object, \"~destructor\", nil)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to call destructor: %w\", err)\n\t}\n\n\tif result != nil {\n\t\treturn fmt.Errorf(\"destructor returned unexpected result: %v\", result)\n\t}\n\treturn nil\n}\n","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/raw_objects/utils.go#L119-L155","documentation":"This error wraps decodeObjectResponse failures in NewRawObject. The constructor call succeeded and the protobuf unmarshalled, but the response content could not be decoded into a Go object: it may be an error response from the native side, an object handle that cannot be decoded, or a serde value of unexpected shape.","triggerScenarios":"NewRawObject invoked via NewCollector, NewTypeBuilder, or media constructors when the native constructor returns an InvocationResponse whose payload cannot be decoded (e.g. native-side error string, unknown object type, decodeRawObjectImpl not registered).","commonSituations":"Constructor rejected the arguments and returned an error payload; Go bindings initialized incorrectly (decode impl missing); object type enum mismatch between native lib and Go bindings.","solutions":["Read the wrapped %w message; it usually contains the actual native-side error text","Verify all required constructor kwargs (e.g. media url/base64) are valid before calling","Reinstall matching versions of the BAML native library and Go module","If the message is 'decodeRawObjectImpl is not set', ensure the baml_go runtime was initialized before use"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if rt == nil { return fmt.Errorf(\"runtime required\") } // and validate constructor kwargs (url/base64 non-empty) before calling","typeGuard":null,"tryCatchPattern":"parsed, err := b.NewTypeBuilder(rt)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to decode object response\") {\n        return fmt.Errorf(\"native constructor rejected call: %w\", err)\n    }\n    return err\n}","preventionTips":["Validate all constructor arguments before calling","Ensure the BAML Go runtime is fully initialized","Match native library and Go module versions"],"tags":["go","ffi","decoding","response"],"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-14T11:17:12.474Z"}