The solution for me was to upgrade protobuf and use absl::string_view
instead of std::string
in my proto messages.
// message.proto
edition = "2023";
import "google/protobuf/cpp_features.proto";
option features.(pb.cpp).string_type=VIEW;
// Now each string field will be string_view in generated code.