Skip to content

Commit

Permalink
sr/protobuf: Compatibility check: FIELD_NAMED_TYPE_CHANGED
Browse files Browse the repository at this point in the history
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
  • Loading branch information
oleiman authored and pgellert committed Aug 12, 2024
1 parent 1072f02 commit bfc715b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/v/pandaproxy/schema_registry/protobuf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,16 @@ struct compatibility_checker {
== pb::FieldDescriptor::Type::TYPE_MESSAGE
|| reader->type()
== pb::FieldDescriptor::Type::TYPE_GROUP;
return type_is_compat
&& check_compatible(
reader->message_type(), writer->message_type());

if (
!type_is_compat
|| reader->message_type()->name()
!= writer->message_type()->name()) {
return false;
} else {
return check_compatible(
reader->message_type(), writer->message_type());
}
}
case pb::FieldDescriptor::Type::TYPE_FLOAT:
case pb::FieldDescriptor::Type::TYPE_DOUBLE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,3 +677,10 @@ SEASTAR_THREAD_TEST_CASE(test_protobuf_compatibility_message_removed) {
R"(syntax = "proto3"; message Outer { message Inner { int32 id = 1;}; Inner x = 1; })",
R"(syntax = "proto3"; message Outer { message Inner { int32 id = 1;}; message Inner2 { int32 id = 1;}; Inner x = 1; })"));
}

SEASTAR_THREAD_TEST_CASE(test_protobuf_compatibility_field_name_type_changed) {
BOOST_REQUIRE(!check_compatible(
pps::compatibility_level::backward,
R"(syntax = "proto3"; message Outer { message Inner { int32 id = 1;}; message Inner2 { int32 id = 1;}; Inner2 x = 1; })",
R"(syntax = "proto3"; message Outer { message Inner { int32 id = 1;}; message Inner2 { int32 id = 1;}; Inner x = 1; })"));
}

0 comments on commit bfc715b

Please sign in to comment.