From 71ff3fea2edc49af737f7e3280738938c3bef06f Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Thu, 19 Jan 2023 12:12:15 -0800 Subject: [PATCH] Automated rollback of commit f60f478f45143b74158380528cb757509d627592. PiperOrigin-RevId: 503231538 --- src/google/protobuf/descriptor.cc | 12 ++++++++++-- src/google/protobuf/descriptor_unittest.cc | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 4905f9b155..fd49431159 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -5626,8 +5626,16 @@ void DescriptorBuilder::CheckFieldJsonNameUniqueness( this_type, field.name(), details.orig_name, existing_type, match.field->name(), name_suffix); - AddError(message_name, field, DescriptorPool::ErrorCollector::NAME, - error_message); + bool involves_default = !details.is_custom || !match.is_custom; + if (syntax == FileDescriptor::SYNTAX_PROTO2 && involves_default) { + // TODO(b/261750676) Upgrade this to an error once downstream protos have + // been fixed. + AddWarning(message_name, field, DescriptorPool::ErrorCollector::NAME, + error_message); + } else { + AddError(message_name, field, DescriptorPool::ErrorCollector::NAME, + error_message); + } } } diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index 9aeee7c36e..99ce3ebc83 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -7016,7 +7016,7 @@ TEST_F(ValidationErrorTest, ValidateJsonNameConflictProto3) { } TEST_F(ValidationErrorTest, ValidateJsonNameConflictProto2) { - BuildFileWithErrors( + BuildFileWithWarnings( "name: 'foo.proto' " "syntax: 'proto2' " "message_type {"