googleapis / google-cloud-python

Google Cloud Client Library for Python
https://googleapis.github.io/google-cloud-python/
Apache License 2.0
4.79k stars 1.52k forks source link

Broken listing zones in `google-cloud-compute` with protobuf=5.28.0 #13070

Open racinmat opened 1 week ago

racinmat commented 1 week ago

Determine this is the right repository

Summary of the issue

Context I tried to list zones in a project using google-cloud-compute SDK and it's broken with the protobuf=5.28.0. I have replicated this behavior with clean python environment.

Expected Behavior: The code from https://cloud.google.com/python/docs/reference/compute/latest/google.cloud.compute_v1.services.zones.ZonesClient#google_cloud_compute_v1_services_zones_ZonesClient_list works.

Actual Behavior:

(gcp_bug) PS C:\Projects\aiops-library\mlops\experiments\google-cloud-compute-bug> python get_zones.py
Traceback (most recent call last):
  File "C:\Projects\aiops-library\mlops\experiments\google-cloud-compute-bug\get_zones.py", line 18, in <module>
    page_result = client.list(request=request)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\E10270\.conda\envs\gcp_bug\Lib\site-packages\google\cloud\compute_v1\services\zones\client.py", line 867, in list
    response = rpc(
               ^^^^
  File "C:\Users\E10270\.conda\envs\gcp_bug\Lib\site-packages\google\api_core\gapic_v1\method.py", line 131, in __call__
    return wrapped_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\E10270\.conda\envs\gcp_bug\Lib\site-packages\google\api_core\grpc_helpers.py", line 76, in error_remapped_callable
    return callable_(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\E10270\.conda\envs\gcp_bug\Lib\site-packages\google\cloud\compute_v1\services\zones\transports\rest.py", line 394, in __call__
    raise core_exceptions.from_http_response(response)
google.api_core.exceptions.BadRequest: 400 GET https://compute.googleapis.com/compute/v1/projects/xxx/zones?project=: Invalid resource field value in the request.

It all works with protobuf==5.27.4. So there must be something broken in https://github.com/protocolbuffers/protobuf/releases/tag/v28.0

API client name and version

google-cloud-compute==1.19.2

Reproduction steps: code

file: get_zones.py

from google.cloud import compute_v1

# Create a client
client = compute_v1.ZonesClient()

# Initialize request argument(s)
request = compute_v1.ListZonesRequest(
    project="xxx",
)

# Make the request
page_result = client.list(request=request)
print(page_result)

Reproduction steps: supporting files

no files needed

Reproduction steps: actual results

see the stack trace above

Reproduction steps: expected results

it prints the zones

OS & version + platform

Windows 10

Python environment

python 3.11.9

Python dependencies

(gcp_bug) PS C:\Projects\aiops-library\mlops\experiments\google-cloud-compute-bug> pip freeze                                                
cachetools==5.5.0
certifi==2024.8.30
charset-normalizer==3.3.2
google-api-core==2.19.2
google-auth==2.34.0
google-cloud-compute==1.19.2
googleapis-common-protos==1.65.0
grpcio==1.66.1
grpcio-status==1.62.3
idna==3.8
proto-plus==1.24.0
protobuf==4.25.4
pyasn1==0.6.0
pyasn1_modules==0.4.0
requests==2.32.3
rsa==4.9
urllib3==2.2.2
parthea commented 1 week ago

Hi @racinmat,

Thanks for reporting this issue. The issue has been fixed upstream in https://github.com/protocolbuffers/protobuf/pull/18159. We'll keep this issue open until a new version of protobuf is available.

racinmat commented 1 week ago

Root cause bug in python is https://github.com/protocolbuffers/protobuf/issues/18045 for cross-reference