-
Notifications
You must be signed in to change notification settings - Fork 96
Description
There is a bug in the initialization of timeout inside the PollingFuture class, where the default value passed into various methods is of type object when it is expected to be an int, float, or None.
- Link to _DEFAULT_VALUE instantiation inside the PollingFuture class
- Downstream methods that expect type
int(orNone, based on traceback): PollingFuture.result and PollingFuture.exception
The below example uses the bigquery client to generate and execute an Operation, and then demonstrates the raised error when attempting to access the .exception method.
Environment Details
Windows 10
Python 3.9.5
pip 21.1.1
pip packages:
google-cloud-bigquery==3.11.4
google-api-core==2.11.1
Steps to reproduce
python -m venv google_api_testgoogle_api_test\scripts\pip install google-cloud-bigquery google-api-core
Code Example
from google.cloud import bigquery
client = bigquery.client.Client()
job = client.query(
"""
SELECT
CONCAT(
'https://stackoverflow.com/questions/',
CAST(id as STRING)) as url,
view_count
FROM `bigquery-public-data.stackoverflow.posts_questions`
WHERE tags like '%google-bigquery%'
ORDER BY RAND() DESC"""
)
job.exception()
Stack Trace
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "{WINDOWS_ROOT}\google_api_test\lib\site-packages\google\api_core\future\polling.py", line 282, in exception
self._blocking_poll(timeout=timeout)
File "{WINDOWS_ROOT}\google_api_test\lib\site-packages\google\cloud\bigquery\job\query.py", line 1257, in _blocking_poll
super(QueryJob, self)._blocking_poll(timeout=timeout, **kwargs)
File "{WINDOWS_ROOT}\google_api_test\lib\site-packages\google\api_core\future\polling.py", line 137, in _blocking_poll
polling(self._done_or_raise)(retry=retry)
File "{WINDOWS_ROOT}\google_api_test\lib\site-packages\google\api_core\retry.py", line 349, in retry_wrapped_func
return retry_target(
File "{WINDOWS_ROOT}\google_api_test\lib\site-packages\google\api_core\retry.py", line 191, in retry_target
return target()
File "{WINDOWS_ROOT}\google_api_test\lib\site-packages\google\cloud\bigquery\job\query.py", line 1379, in _done_or_raise
self._reload_query_results(retry=retry, timeout=transport_timeout)
File "{WINDOWS_ROOT}\google_api_test\lib\site-packages\google\cloud\bigquery\job\query.py", line 1360, in _reload_query_results
self._query_results = self._client._get_query_results(
File "{WINDOWS_ROOT}\google_api_test\lib\site-packages\google\cloud\bigquery\client.py", line 1898, in _get_query_results
timeout = max(timeout, _MIN_GET_QUERY_RESULTS_TIMEOUT)
TypeError: '>' not supported between instances of 'int' and 'object'
Side Note:
This example does not directly demonstrate the error effect on the job.result() function as, in this example through BigQuery, the PollingFuture.result method is wrapped in QueryJob.result (link to class). This wrapper overrides the invalid timeout with an acceptable timeout value of None (link to argument)