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 v4 error - Descriptors cannot be created directly.

See original GitHub issue

Announcement: Azure python function apps pinning protobuf package to v4.x.x directly or indirectly (ex. use another library which requires protobuf v4) malfunction as protobuf v4.x.x introduces breaking changes

Problem: There is breaking change introduced in new protobuf package v4.x.x version, ref at https://github.com/protocolbuffers/protobuf/issues/10064

Azure python function worker currently using protobuf package of v3.x.x version. Since protobuf v4 is released, it is observed many python function apps which pin protobuf to v4.x.x in the requirement.txt are affected. Detailed error logs are as below. Caution, if your function app is affected, please refer to mitigation step section below!!!

 [Information] File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/protos/shared/NullableTypes_pb2.py", line 38, in <module>
 [Information] _descriptor.FieldDescriptor(
 [Information] File "/home/site/wwwroot/.python_packages/lib/site-packages/google/protobuf/descriptor.py", line 560, in __new__
 [Information] _message.Message._CheckCalledFromGeneratedFile()
 [Error] TypeError: Descriptors cannot not be created directly.
 [Information] 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.
 [Information] If you cannot immediately regenerate your protos, some other possible workarounds are:
 [Information] 1. Downgrade the protobuf package to 3.20.x or lower.
 [Information] 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
 [Information] More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

Mitigation Two ways to mitigate the issue:

  1. Set PYTHON_ISOLATE_WORKER_DEPENDENCIES in AppSetting to 1. (For reference, please check https://docs.microsoft.com/en-us/azure/azure-functions/functions-app-settings#python_isolate_worker_dependencies-preview)
  2. For users not requiring protobuf v4.x.x versions in your function app requirement.txt, please pin protobuf >= 3.19.3, == 3.*

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
gerardsimonscommented, Aug 1, 2022

Thanks for posting this, it is indeed a terrible error since it only started showing up for me when switching to a Premium function and looking at the logs in the advanced tools … This is an awful awful bug that has caused my company a lot of time and effort, please fix!

2reactions
gavin-aguiarcommented, Aug 5, 2022

@gerardsimons we have fixed this bug and is currently being rolled out. Runtime version 4.9.1 will have the fix for this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - TypeError: Descriptors cannot not be created directly
TypeError : Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out of date...
Read more >
Typeerror: descriptors cannot not be created directly ( Solved )
Typeerror: descriptors cannot not be created directly error occurs because of incompatibility of protobuf package. This incompatibility can be direct or ...
Read more >
[Protobuf] TypeError: Descriptors cannot not be created directly.
We get this error on startup of the inference server with mlserver==1.0.1 so that the server is completely blocked from working on requests....
Read more >
TypeError: Descriptors cannot not be created directly [Fixed]
The error TypeError: Descriptors cannot not be created directly occurs because there has been a breaking change in `protobuf` version 4. To solve...
Read more >
TypeError: Descriptors cannot not be created directly - Streamlit
I get the following error when deploying the app. I dont use the package mentioned in the erorr, any ideas? Error:
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