Skip to content

[BUILD] Build break using protoc 3.14 #3209

@marcalff

Description

@marcalff
[ 70%] Building CXX object exporters/otlp/CMakeFiles/otlp_recordable_test.dir/test/otlp_recordable_test.cc.o
In file included from /usr/include/gtest/gtest.h:62,
                 from /home/malff/CODE/MARC_GITHUB/opentelemetry-cpp/exporters/otlp/test/otlp_recordable_test.cc:4:
/home/malff/CODE/MARC_GITHUB/opentelemetry-cpp/exporters/otlp/test/otlp_recordable_test.cc: In member function ‘virtual void opentelemetry::v2::exporter::otlp::OtlpRecordable_SetInstrumentationScopeWithAttributes_Test::TestBody()’:
/home/malff/CODE/MARC_GITHUB/opentelemetry-cpp/exporters/otlp/test/otlp_recordable_test.cc:139:40: error: ‘const class opentelemetry::proto::common::v1::AnyValue’ has no member named ‘has_string_value’; did you mean ‘set_string_value’?
  139 |   ASSERT_TRUE(proto_attributes.value().has_string_value());
      |                                        ^~~~~~~~~~~~~~~~
make[2]: *** [exporters/otlp/CMakeFiles/otlp_recordable_test.dir/build.make:76: exporters/otlp/CMakeFiles/otlp_recordable_test.dir/test/otlp_recordable_test.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:6262: exporters/otlp/CMakeFiles/otlp_recordable_test.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

The issue with this line:

ASSERT_TRUE(proto_attributes.value().has_string_value());

is that has_string_value() was added only in protoc 3.15, and this breaks with protoc 3.14.

Now Proto3 Oneof fields have "has" methods for checking their presence in
C++.

The break can be seen also in CI in the include-what-you-use logs:

[ 76%] Building CXX object exporters/otlp/CMakeFiles/otlp_recordable_test.dir/test/otlp_recordable_test.cc.o
/home/runner/work/opentelemetry-cpp/opentelemetry-cpp/exporters/otlp/test/otlp_recordable_test.cc:139:40: error: no member named 'has_string_value' in 'opentelemetry::proto::common::v1::AnyValue'
  ASSERT_TRUE(proto_attributes.value().has_string_value());
              ~~~~~~~~~~~~~~~~~~~~~~~~ ^

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions