Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/v/pandaproxy/schema_registry/protobuf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,9 @@ struct compatibility_checker {

for (int i = 0; i < writer->nested_type_count(); ++i) {
auto w = writer->nested_type(i);
if (w->options().has_map_entry()) {
continue;
}
auto r = reader->FindNestedTypeByName(w->name());
if (!r) {
compat_result.emplace<proto_incompatibility>(
Expand Down
65 changes: 65 additions & 0 deletions src/v/pandaproxy/schema_registry/test/compatibility_protobuf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,71 @@ service FooService {
)"));
}

SEASTAR_THREAD_TEST_CASE(test_protobuf_compatibility_remove_map_field) {
constexpr std::string_view with_map = R"(syntax = "proto3";

message Product {
string name = 1;
map<string, string> tags = 10;
}
)";
constexpr std::string_view without_map = R"(syntax = "proto3";

message Product {
string name = 1;
}
)";

BOOST_REQUIRE(check_compatible(
pps::compatibility_level::backward, without_map, with_map));
BOOST_REQUIRE(check_compatible(
pps::compatibility_level::backward_transitive, without_map, with_map));
BOOST_REQUIRE(
check_compatible(pps::compatibility_level::full, without_map, with_map));
BOOST_REQUIRE(check_compatible(
pps::compatibility_level::full_transitive, without_map, with_map));

BOOST_REQUIRE(check_compatible(
pps::compatibility_level::forward, with_map, without_map));
BOOST_REQUIRE(check_compatible(
pps::compatibility_level::forward_transitive, with_map, without_map));
}

SEASTAR_THREAD_TEST_CASE(test_protobuf_compatibility_map_in_nested_message) {
constexpr std::string_view with_map = R"(syntax = "proto3";

message Outer {
message Inner {
string id = 1;
map<string, string> tags = 2;
}
Inner inner = 1;
}
)";
constexpr std::string_view without_map = R"(syntax = "proto3";

message Outer {
message Inner {
string id = 1;
}
Inner inner = 1;
}
)";
BOOST_REQUIRE(check_compatible(
pps::compatibility_level::backward, without_map, with_map));
BOOST_REQUIRE(check_compatible(
pps::compatibility_level::backward_transitive, without_map, with_map));
BOOST_REQUIRE(
check_compatible(pps::compatibility_level::full, without_map, with_map));
BOOST_REQUIRE(check_compatible(
pps::compatibility_level::full_transitive, without_map, with_map));

BOOST_REQUIRE(check_compatible(
pps::compatibility_level::forward, with_map, without_map));
BOOST_REQUIRE(check_compatible(
pps::compatibility_level::forward_transitive, with_map, without_map));
}

SEASTAR_THREAD_TEST_CASE(test_protobuf_compatibility_message_removed) {
BOOST_REQUIRE(!check_compatible(
pps::compatibility_level::backward,
Expand Down
Loading