Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gavin-aguiar opened this issue Oct 24, 2023 · 1 comment
Assignees

Comments

@gavin-aguiar
Copy link
Contributor

gavin-aguiar commented Oct 24, 2023

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

  • Add the app setting PYTHON_ISOLATE_WORKER_DEPENDENCIES to 1. This will force workers to isolate its dependencies and not use those brought with the app. Or
  • Update your dependencies to bring in the updated version of grpcio, grpcio-tools and/or protobuf to at least 1.54.2 or 4.22.
@gavin-aguiar gavin-aguiar self-assigned this Oct 24, 2023
@gavin-aguiar gavin-aguiar pinned this issue Oct 24, 2023
@up2pixy
Copy link

up2pixy commented Oct 24, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants