Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
335 stars 103 forks source link

ImportError: cannot import name 'builder' from 'google.protobuf.internal' #1332

Open gavin-aguiar opened 11 months ago

gavin-aguiar commented 11 months ago

Background

Recently, we upgraded grpcio and grpcio-tools versions to 1.54.2 in the Python worker, which updated the internal protobuf to 4.22. This was done to multiple CVEs reported and was required to ensure the security fixes were taken in.

This has caused some of the apps to fail with errors:

Microsoft.Azure.WebJobs.Script.Workers.WorkerProcessExitException : 
python exited with code 1 (0x1) ---> System.Exception : 
ImportError: cannot import name 'builder' from 'google.protobuf.internal' (/home/site/wwwroot/.python_packages/lib/site-packages/google/protobuf/internal/__init__.py),
End of inner exception

Root Cause

Since we prioritize the customer's libraries before loading the Python worker dependency, an old version of protobuf is loaded, which conflicts with the newer version used by the worker.

How to Mitigate

up2pixy commented 11 months ago

Could you please also update this page to reflect the new supported version change? https://learn.microsoft.com/en-us/azure/azure-functions/recover-python-functions?tabs=vscode%2Cbash&pivots=python-mode-decorators#troubleshoot-errors-with-protocol-buffers