From 164b8dd44080a3528b3c20cfd15e0d65a45e96fb Mon Sep 17 00:00:00 2001 From: Mike Mann Date: Wed, 2 Nov 2022 17:58:29 -0700 Subject: [PATCH 1/3] Fix incorrect Protobuf FileDescriptor references Fixes several well known types were referencing incorrect descriptors. Additionally, changes the field behavior and source context imports, which are part of the standard protobuf distribution, to google.golang.org/protobuf instead of google.golang.org/genproto. --- schemaregistry/serde/protobuf/protobuf.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/schemaregistry/serde/protobuf/protobuf.go b/schemaregistry/serde/protobuf/protobuf.go index 382b77dbb..a93e863d5 100644 --- a/schemaregistry/serde/protobuf/protobuf.go +++ b/schemaregistry/serde/protobuf/protobuf.go @@ -40,19 +40,21 @@ import ( "google.golang.org/genproto/googleapis/type/fraction" "google.golang.org/genproto/googleapis/type/latlng" "google.golang.org/genproto/googleapis/type/money" + "google.golang.org/genproto/googleapis/type/month" "google.golang.org/genproto/googleapis/type/postaladdress" "google.golang.org/genproto/googleapis/type/quaternion" "google.golang.org/genproto/googleapis/type/timeofday" - "google.golang.org/genproto/protobuf/field_mask" - "google.golang.org/genproto/protobuf/source_context" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" "google.golang.org/protobuf/types/descriptorpb" "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/apipb" "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/emptypb" + "google.golang.org/protobuf/types/known/fieldmaskpb" + "google.golang.org/protobuf/types/known/sourcecontextpb" "google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/typepb" @@ -88,17 +90,17 @@ func init() { "google/type/fraction.proto": fraction.File_google_type_fraction_proto, "google/type/latlng.proto": latlng.File_google_type_latlng_proto, "google/type/money.proto": money.File_google_type_money_proto, - "google/type/month.proto": money.File_google_type_money_proto, + "google/type/month.proto": month.File_google_type_month_proto, "google/type/postal_address.proto": postaladdress.File_google_type_postal_address_proto, "google/type/quaternion.proto": quaternion.File_google_type_quaternion_proto, "google/type/timeofday.proto": timeofday.File_google_type_timeofday_proto, "google/protobuf/any.proto": anypb.File_google_protobuf_any_proto, - "google/protobuf/api.proto": anypb.File_google_protobuf_any_proto, + "google/protobuf/api.proto": apipb.File_google_protobuf_api_proto, "google/protobuf/descriptor.proto": descriptorpb.File_google_protobuf_descriptor_proto, "google/protobuf/duration.proto": durationpb.File_google_protobuf_duration_proto, "google/protobuf/empty.proto": emptypb.File_google_protobuf_empty_proto, - "google/protobuf/field_mask.proto": field_mask.File_google_protobuf_field_mask_proto, - "google/protobuf/source_context.proto": source_context.File_google_protobuf_source_context_proto, + "google/protobuf/field_mask.proto": fieldmaskpb.File_google_protobuf_field_mask_proto, + "google/protobuf/source_context.proto": sourcecontextpb.File_google_protobuf_source_context_proto, "google/protobuf/struct.proto": structpb.File_google_protobuf_struct_proto, "google/protobuf/timestamp.proto": timestamppb.File_google_protobuf_timestamp_proto, "google/protobuf/type.proto": typepb.File_google_protobuf_type_proto, From b2fa4e12b245ecf391f1c36876f0d54f822b37b1 Mon Sep 17 00:00:00 2001 From: PrasanthV454 Date: Mon, 20 Feb 2023 22:23:08 +0530 Subject: [PATCH 2/3] maintaining same format for producer and consumer in protobuf examples --- .../protobuf_producer_example/my_record.pb.go | 74 +++++++++---------- .../protobuf_producer_example/my_record.proto | 2 +- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/examples/protobuf_producer_example/my_record.pb.go b/examples/protobuf_producer_example/my_record.pb.go index a04c90acf..5f3466f11 100644 --- a/examples/protobuf_producer_example/my_record.pb.go +++ b/examples/protobuf_producer_example/my_record.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.0 -// protoc v3.19.1 -// source: examples/protobuf_producer_example/my_record.proto +// protoc-gen-go v1.28.1 +// protoc v3.21.12 +// source: my_record.proto package main @@ -31,7 +31,7 @@ type MyRecord struct { func (x *MyRecord) Reset() { *x = MyRecord{} if protoimpl.UnsafeEnabled { - mi := &file_examples_protobuf_producer_example_my_record_proto_msgTypes[0] + mi := &file_my_record_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -44,7 +44,7 @@ func (x *MyRecord) String() string { func (*MyRecord) ProtoMessage() {} func (x *MyRecord) ProtoReflect() protoreflect.Message { - mi := &file_examples_protobuf_producer_example_my_record_proto_msgTypes[0] + mi := &file_my_record_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -57,7 +57,7 @@ func (x *MyRecord) ProtoReflect() protoreflect.Message { // Deprecated: Use MyRecord.ProtoReflect.Descriptor instead. func (*MyRecord) Descriptor() ([]byte, []int) { - return file_examples_protobuf_producer_example_my_record_proto_rawDescGZIP(), []int{0} + return file_my_record_proto_rawDescGZIP(), []int{0} } func (x *MyRecord) GetProductName() string { @@ -67,36 +67,34 @@ func (x *MyRecord) GetProductName() string { return "" } -var File_examples_protobuf_producer_example_my_record_proto protoreflect.FileDescriptor - -var file_examples_protobuf_producer_example_my_record_proto_rawDesc = []byte{ - 0x0a, 0x32, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x5f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x72, 0x5f, 0x65, 0x78, 0x61, - 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6d, 0x79, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x2c, 0x0a, 0x08, 0x4d, 0x79, - 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, - 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, - 0x64, 0x75, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x6d, 0x61, - 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +var File_my_record_proto protoreflect.FileDescriptor + +var file_my_record_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x6d, 0x79, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x2c, 0x0a, 0x08, 0x4d, 0x79, 0x52, 0x65, 0x63, + 0x6f, 0x72, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, + 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x3b, 0x6d, 0x61, 0x69, 0x6e, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_examples_protobuf_producer_example_my_record_proto_rawDescOnce sync.Once - file_examples_protobuf_producer_example_my_record_proto_rawDescData = file_examples_protobuf_producer_example_my_record_proto_rawDesc + file_my_record_proto_rawDescOnce sync.Once + file_my_record_proto_rawDescData = file_my_record_proto_rawDesc ) -func file_examples_protobuf_producer_example_my_record_proto_rawDescGZIP() []byte { - file_examples_protobuf_producer_example_my_record_proto_rawDescOnce.Do(func() { - file_examples_protobuf_producer_example_my_record_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_protobuf_producer_example_my_record_proto_rawDescData) +func file_my_record_proto_rawDescGZIP() []byte { + file_my_record_proto_rawDescOnce.Do(func() { + file_my_record_proto_rawDescData = protoimpl.X.CompressGZIP(file_my_record_proto_rawDescData) }) - return file_examples_protobuf_producer_example_my_record_proto_rawDescData + return file_my_record_proto_rawDescData } -var file_examples_protobuf_producer_example_my_record_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_examples_protobuf_producer_example_my_record_proto_goTypes = []interface{}{ +var file_my_record_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_my_record_proto_goTypes = []interface{}{ (*MyRecord)(nil), // 0: main.MyRecord } -var file_examples_protobuf_producer_example_my_record_proto_depIdxs = []int32{ +var file_my_record_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name @@ -104,13 +102,13 @@ var file_examples_protobuf_producer_example_my_record_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { file_examples_protobuf_producer_example_my_record_proto_init() } -func file_examples_protobuf_producer_example_my_record_proto_init() { - if File_examples_protobuf_producer_example_my_record_proto != nil { +func init() { file_my_record_proto_init() } +func file_my_record_proto_init() { + if File_my_record_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_examples_protobuf_producer_example_my_record_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_my_record_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MyRecord); i { case 0: return &v.state @@ -127,18 +125,18 @@ func file_examples_protobuf_producer_example_my_record_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_examples_protobuf_producer_example_my_record_proto_rawDesc, + RawDescriptor: file_my_record_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_examples_protobuf_producer_example_my_record_proto_goTypes, - DependencyIndexes: file_examples_protobuf_producer_example_my_record_proto_depIdxs, - MessageInfos: file_examples_protobuf_producer_example_my_record_proto_msgTypes, + GoTypes: file_my_record_proto_goTypes, + DependencyIndexes: file_my_record_proto_depIdxs, + MessageInfos: file_my_record_proto_msgTypes, }.Build() - File_examples_protobuf_producer_example_my_record_proto = out.File - file_examples_protobuf_producer_example_my_record_proto_rawDesc = nil - file_examples_protobuf_producer_example_my_record_proto_goTypes = nil - file_examples_protobuf_producer_example_my_record_proto_depIdxs = nil + File_my_record_proto = out.File + file_my_record_proto_rawDesc = nil + file_my_record_proto_goTypes = nil + file_my_record_proto_depIdxs = nil } diff --git a/examples/protobuf_producer_example/my_record.proto b/examples/protobuf_producer_example/my_record.proto index accae76b3..ebd131894 100644 --- a/examples/protobuf_producer_example/my_record.proto +++ b/examples/protobuf_producer_example/my_record.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package main; -option go_package="main"; +option go_package="./;main"; message MyRecord { string productName = 1; From 13416ee45f56d3173680923a906e90240b2d1003 Mon Sep 17 00:00:00 2001 From: Milind L Date: Tue, 25 Apr 2023 14:17:49 +0530 Subject: [PATCH 3/3] Add changelog entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 356aa3ad3..800b1650a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Confluent's Golang client for Apache Kafka +## vNext + + * Fixed incorrect protofbuf FileDescriptor references (#989, @Mrmann87). + ## v2.1.0 * Added Consumer `SeekPartitions()` method to seek multiple partitions at