question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Protobuf version incompatibility

See original GitHub issue

Description [NOTE]: # Pip install grpc+google-cloud-core+newrelic end up with a newrelic version which is not compatible with the protobuf installed

Expected Behavior [NOTE]: # Library should not crash when importing it

Troubleshooting or NR Diag results [NOTE]: #

~ ❯ python -c 'import newrelic.agent'                                                                                                                            🐍 testenv 3.9.9   2.7.4
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/xxx/.pyenv/versions/testenv/lib/python3.9/site-packages/newrelic/agent.py", line 15, in <module>
    from newrelic.config import (
  File "/Users/xxx/.pyenv/versions/testenv/lib/python3.9/site-packages/newrelic/config.py", line 26, in <module>
    import newrelic.api.application
  File "/Users/xxx/.pyenv/versions/testenv/lib/python3.9/site-packages/newrelic/api/application.py", line 19, in <module>
    import newrelic.core.agent
  File "/Users/xxx/.pyenv/versions/testenv/lib/python3.9/site-packages/newrelic/core/agent.py", line 33, in <module>
    import newrelic.core.application
  File "/Users/xxx/.pyenv/versions/testenv/lib/python3.9/site-packages/newrelic/core/application.py", line 32, in <module>
    from newrelic.core.config import global_settings
  File "/Users/xxx/.pyenv/versions/testenv/lib/python3.9/site-packages/newrelic/core/config.py", line 44, in <module>
    from newrelic.core.infinite_tracing_pb2 import (  # pylint: disable=W0611,C0412  # noqa: F401
  File "/Users/xxx/.pyenv/versions/testenv/lib/python3.9/site-packages/newrelic/core/infinite_tracing_pb2.py", line 45, in <module>
    _descriptor.FieldDescriptor(
  File "/Users/xxx/.pyenv/versions/testenv/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 560, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

Steps to Reproduce [NOTE]:

# New python virtualenv with nothing installed
pyenv virtualenv 3.9.9 testenv
 pyenv activate testenv

# Install dependencies
pip install grpc google-api-corenewrelic

# Run python which just imports newrelic.agent
python -c 'import newrelic.agent'

Your Environment [TIP]: # Python 3.9.9 (shouldn’t be relevant) and latest versions of grpc/google-cloud-core/newrelic. Happens on my Mac and inside docker too.

Additional context [TIP]: # I have seen that in newrelic’s setup.py the grpc and protobuf version is only in the dependencies when using newrelic[infinite-tracing], but in this case we’re not using it. Since we installed grpc/protobuf for other reasons, the lib seems to think infinite-tracing is enabled and the protobuf version required is the correct one, which it isn’t and then crashes

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
drewbrewcommented, May 26, 2022

Google yanked protobuf 4.21, FWIW.

0reactions
TimPansinocommented, May 26, 2022

Seeing as Google has yanked protobuf 4.21.0, it seems the issue is currently not a problem with the latest non-yanked version of protobuf.

It looks like a breaking change with the introduction of protobuf 4, anyone seeing this issue can safely pin protobuf<4 in their requirements to avoid this issue. We’ll get this version pinned in our next release while we wait for a stable release in the 4 series.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Protobuf version incompatibility · Issue #20 - GitHub
First check which version you are using: protoc ---version . It should show libprotoc 3.2.0 . If that is the case, then you...
Read more >
Overview | Protocol Buffers - Google Developers
Protocol buffers provide a language-neutral, platform-neutral, extensible mechanism for serializing structured data in a forward-compatible ...
Read more >
Protocol buffer compatibility across library versions
Hi, Lets say my proto (abcd.proto) is compiled with the protoc compiler version 2.0.3 and my application also links to the corresponding runtime...
Read more >
Protobuf version mismatch - Stack Overflow
You might have two different versions of protobuf installed. Check. protoc --version. If it is different from 3.4.0.
Read more >
Protocol Buffers Best Practices for Backward and Forward ...
It can accept input crafted by later versions of protobuf. The sender is backward compatible because it's creating output that can be consumed ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found