[fix][ProtobufNativeSchema] Fix build by converting abseil string_view to std::string by dannf · Pull Request #527 · apache/pulsar-client-cpp · GitHub
Skip to content

[fix][ProtobufNativeSchema] Fix build by converting abseil string_view to std::string#527

Merged
BewareMyPower merged 1 commit into
apache:mainfrom
dannf:cast-abseil-strings
Dec 8, 2025
Merged

[fix][ProtobufNativeSchema] Fix build by converting abseil string_view to std::string#527
BewareMyPower merged 1 commit into
apache:mainfrom
dannf:cast-abseil-strings

Conversation

@dannf

@dannf dannf commented Dec 7, 2025

Copy link
Copy Markdown
Contributor

Fixes #478

Motivation

Our libpulsar builds started failing with latest upstream dependencies (abseil-cpp/protobuf). After creating this patch, I noticed @cho-m had already reported an issue and suggested a couple fixes, which are likely better than this. But that was months ago, so I figured I'd open a PR to push the conversation forward.

Modifications

Explicitly convert absl string_view to std::string for use in the schemaJson.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is a trivial rework / code cleanup without any test coverage.

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    No user-visible changes.

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

This resolves the following build failure using abseil-cpp 20250814.1:

```
[  1%] Building CXX object lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o
cd /home/build/pulsar-client-cpp/build/lib && /usr/local/bin/c++ -DBOOST_ALLOW_DEPRECATED_HEADERS -DBOOST_ALL_NO_LIB -DBUILDING_PULSAR -DHAS_SNAPPY=0 -DHAS_ZSTD=0 -DPULSAR_AUXV_GETAUXVAL_PRESENT -I/home/build/pulsar-client-cpp -I/home/build/pulsar-client-cpp/include -I/home/build/pulsar-client-cpp/build/include -I/home/build/pulsar-client-cpp/build/generated -I/home/build/pulsar-client-cpp/build/generated/lib -Wno-array-bounds -O2 -g -DNDEBUG -std=gnu++17 -fPIC -Wall -Wformat-security -Wvla -Werror -Wno-sign-compare -Wno-deprecated-declarations -Wno-error=cpp -msse4.2 -mpclmul -fdiagnostics-show-option -fdiagnostics-color -fvisibility=hidden -MD -MT lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o -MF CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o.d -o CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o -c /home/build/pulsar-client-cpp/lib/ProtobufNativeSchema.cc
/home/build/pulsar-client-cpp/lib/ProtobufNativeSchema.cc: In function 'pulsar::SchemaInfo pulsar::createProtobufNativeSchema(const google::protobuf::Descriptor*)':
/home/build/pulsar-client-cpp/lib/ProtobufNativeSchema.cc:42:67: error: invalid initialization of reference of type 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'} from expression of type 'absl::lts_20250814::string_view' {aka 'std::basic_string_view<char>'}
   42 |     const std::string& rootMessageTypeName = descriptor->full_name();
      |                                              ~~~~~~~~~~~~~~~~~~~~~^~
/home/build/pulsar-client-cpp/lib/ProtobufNativeSchema.cc:43:69: error: invalid initialization of reference of type 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'} from expression of type 'absl::lts_20250814::string_view' {aka 'std::basic_string_view<char>'}
   43 |     const std::string& rootFileDescriptorName = fileDescriptor->name();
      |                                                 ~~~~~~~~~~~~~~~~~~~~^~
make[2]: *** [lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/build.make:1052: lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o] Error 1
```

Signed-off-by: dann frazier <dann.frazier@chainguard.dev>
Comment thread lib/ProtobufNativeSchema.cc
@dannf

dannf commented Dec 7, 2025

Copy link
Copy Markdown
Contributor Author

@BewareMyPower

Copy link
Copy Markdown
Contributor

@BewareMyPower BewareMyPower added this to the 4.0.0 milestone Dec 8, 2025
@BewareMyPower BewareMyPower merged commit adf3c7c into apache:main Dec 8, 2025
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Build fails with Protobuf 30 from type changes

3 participants