[X] I determined this is the correct repository in which to report this bug.
Summary of the issue
While reviewing an API I observed that it does not work for service account credentials while it does for ADC credentials. The PIP library used below is google-cloud-storage-transfer v 1.11.4. Note how using the ADC credentials works (I also confirmed these work with the HTTP request via https://cloud.google.com/storage-transfer/docs/reference/rest/v1/transferJobs/list), while using service account credentials does not. See below how I start with ADC creds and it works fine (albeit the need to use json.dumps instead of being able to pass in a dictionary for filter which seems a bit weird), and then trying to do the same with a client using service account credentials throws an UNKNOWN error.
API client name and version
google-cloud-storage-transfer == 1.11.4
Reproduction steps: code
└─$ python3
Python 3.11.9 (main, Apr 10 2024, 13:16:36) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.auth
>>> from google.cloud import storage_transfer_v1
>>> filter_value = {"projectId":"<project_id>"}
>>> project_id, cred = google.auth.default()
>>> storage_transfer_client = storage_transfer_v1.StorageTransferServiceClient(credentials = cred)
>>> import json
>>> filter_value = json.dumps(filter_value)
>>> request = storage_transfer_v1.ListTransferJobsRequest(filter=filter_value)
>>> transfer_job_list = storage_transfer_client.list_transfer_jobs(request=request)
>>> print(transfer_job_list)
ListTransferJobsPager<transfer_jobs {
name: "transferJobs/1[TRUNCATED]"
project_id: "<project_id>"
transfer_spec {
[TRUNCATED]
>>> service_cred = google.auth.load_credentials_from_file(filename = "/home/[TRUNCATED]/key.json")
>>> service_cred
(<google.oauth2.service_account.Credentials object at [TRUNCATED]>, '<project_id>')
>>> service_storage_transfer_client = storage_transfer_v1.StorageTransferServiceClient(credentials = service_cred)
>>> service_request = storage_transfer_v1.ListTransferJobsRequest(filter=filter_value)
>>> service_transfer_job_list = service_storage_transfer_client.list_transfer_jobs(request=service_request)
Traceback (most recent call last):
File "/home/kali/.local/lib/python3.11/site-packages/google/api_core/grpc_helpers.py", line 76, in error_remapped_callable
return callable_(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kali/.local/lib/python3.11/site-packages/grpc/_channel.py", line 1181, in __call__
return _end_unary_response_blocking(state, call, False, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kali/.local/lib/python3.11/site-packages/grpc/_channel.py", line 1006, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "Getting metadata from plugin failed with error: 'tuple' object has no attribute 'before_request'"
debug_error_string = "UNKNOWN:Error received from peer {created_time:"2024-07-16T01:27:47.881913035-04:00", grpc_status:14, grpc_message:"Getting metadata from plugin failed with error: \'tuple\' object has no attribute \'before_request\'"}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/kali/.local/lib/python3.11/site-packages/google/cloud/storage_transfer_v1/services/storage_transfer_service/client.py", line 1109, in list_transfer_jobs
response = rpc(
^^^^
File "/home/kali/.local/lib/python3.11/site-packages/google/api_core/gapic_v1/method.py", line 131, in __call__
return wrapped_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kali/.local/lib/python3.11/site-packages/google/api_core/grpc_helpers.py", line 78, in error_remapped_callable
raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.ServiceUnavailable: 503 Getting metadata from plugin failed with error: 'tuple' object has no attribute 'before_request'
>>> service_transfer_job_list = service_storage_transfer_client.list_transfer_jobs(request=request)
Traceback (most recent call last):
File "/home/kali/.local/lib/python3.11/site-packages/google/api_core/grpc_helpers.py", line 76, in error_remapped_callable
return callable_(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kali/.local/lib/python3.11/site-packages/grpc/_channel.py", line 1181, in __call__
return _end_unary_response_blocking(state, call, False, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kali/.local/lib/python3.11/site-packages/grpc/_channel.py", line 1006, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "Getting metadata from plugin failed with error: 'tuple' object has no attribute 'before_request'"
debug_error_string = "UNKNOWN:Error received from peer {grpc_message:"Getting metadata from plugin failed with error: \'tuple\' object has no attribute \'before_request\'", grpc_status:14, created_time:"2024-07-16T01:28:03.214477625-04:00"}"
>
Reproduction steps: supporting files
file: mydata.csv
alpha,1,3
beta,2,5
### Reproduction steps: actual results
file: output.txtmydata.csv
```
Calculated: foo
```
### Reproduction steps: expected results
The API should work the same as ADC credentials
### OS & version + platform
Kali Linux + Python
### Python environment
Python 3.11.9
### Python dependencies
See above for dependency
Determine this is the right repository
Summary of the issue
While reviewing an API I observed that it does not work for service account credentials while it does for ADC credentials. The PIP library used below is google-cloud-storage-transfer v 1.11.4. Note how using the ADC credentials works (I also confirmed these work with the HTTP request via https://cloud.google.com/storage-transfer/docs/reference/rest/v1/transferJobs/list), while using service account credentials does not. See below how I start with ADC creds and it works fine (albeit the need to use json.dumps instead of being able to pass in a dictionary for filter which seems a bit weird), and then trying to do the same with a client using service account credentials throws an UNKNOWN error.
API client name and version
google-cloud-storage-transfer == 1.11.4
Reproduction steps: code
Reproduction steps: supporting files
file: mydata.csv