tableau / server-client-python

A Python library for the Tableau Server REST API
https://tableau.github.io/server-client-python/
MIT License
655 stars 420 forks source link

Tableau REST API request call conflict because of wrong variable initialization #1327

Closed andersonfellipe closed 7 months ago

andersonfellipe commented 8 months ago

Describe the bug I use the tableauserverclient lib to publish data to a Tableau server. I have noticed that the version 0.26 introduced a code to run long requests on second thread #1212. This code has an issue that is causing intermittent request conflicts.

Versions

To Reproduce Use the method datasources.publish to upload a hyper file to a Tableau server. If you do it multiple times (>10) eventually you will get a generic error that may be Internal Server Error (error code 500000) or Bad Request (error code 400011).

The issue is on the line 80

https://github.com/tableau/server-client-python/blob/3ec49bccdb5cc2fb038476ddd77bcb0e1e32df56/tableauserverclient/server/endpoint/endpoint.py#L80

Then this if condition on the line 110 is True and the None is returned. According to the comment inside the if, it should be True only if there is a response to be returned

https://github.com/tableau/server-client-python/blob/72eb3c8500193e4f20defa20c8a6f8bbf34b2f43/tableauserverclient/server/endpoint/endpoint.py#L110

According to the initialization done on the method send_request_while_show_progress_threaded, the line 80 of this file should be

self.async_response = -1

Results This is the sequence of the current log when the request call conflict happens (with received None):

2023-12-13 02:44:23,576 - TSC - DEBUG - Publishing file `file.hyper`, size `851968`
2023-12-13 02:44:23,577 - TSC - INFO - Publishing file.hyper to server
2023-12-13 02:44:23,579 - TSC - DEBUG - request method post, url: fake_tableau_server_url/datasources?datasourceType=hyper&overwrite=true
2023-12-13 02:44:23,580 - TSC - DEBUG - [02:44:23] Begin blocking request to fake_tableau_server_url/datasources?datasourceType=hyper&overwrite=true
2023-12-13 02:44:24,581 - TSC - DEBUG - [02:44:24] Async request returned: received None
2023-12-13 02:44:24,581 - TSC - DEBUG - None
2023-12-13 02:44:24,582 - TSC - DEBUG - [02:44:24] Async request failed: retrying
2023-12-13 02:44:24,582 - TSC - DEBUG - [02:44:24] Begin blocking request to fake_tableau_server_url/datasources?datasourceType=hyper&overwrite=true
2023-12-13 02:44:24,995 - urllib3.connectionpool - DEBUG - https://fake_tableau_server_url.com:443 "POST /fake_api_path/datasources?datasourceType=hyper&overwrite=true HTTP/1.1" 201 None
2023-12-13 02:44:24,995 - TSC - DEBUG - [02:44:24] Call finished
2023-12-13 02:44:24,996 - TSC - DEBUG - [02:44:24] Request complete
2023-12-13 02:44:25,483 - urllib3.connectionpool - DEBUG - https://fake_tableau_server_url.com:443 "POST /fake_api_path/datasources?datasourceType=hyper&overwrite=true HTTP/1.1" 500 None
2023-12-13 02:44:25,484 - TSC - DEBUG - [02:44:25] Call finished
2023-12-13 02:44:25,485 - TSC - DEBUG - [02:44:25] Request complete
2023-12-13 02:44:25,485 - TSC - DEBUG - Response status: <Response [500]>

This is the sequence the log should have (with Waiting....):

2023-12-13 04:44:34,099 - TSC - DEBUG - Publishing file `file.hyper`, size `851968`
2023-12-13 04:44:34,100 - TSC - INFO - Publishing file.hyper to server
2023-12-13 04:44:34,105 - TSC - DEBUG - request method post, url: fake_tableau_server_url/datasources?datasourceType=hyper&overwrite=true
2023-12-13 04:44:34,106 - TSC - DEBUG - [04:44:34] Begin blocking request to fake_tableau_server_url/datasources?datasourceType=hyper&overwrite=true
2023-12-13 04:44:35,108 - TSC - DEBUG - 04:44:35 Waiting....
2023-12-13 04:44:36,335 - urllib3.connectionpool - DEBUG - https://fake_tableau_server_url.com:443 "POST /fake_api_path/datasources?datasourceType=hyper&overwrite=true HTTP/1.1" 201 None
2023-12-13 04:44:36,337 - TSC - DEBUG - [04:44:36] Call finished
2023-12-13 04:44:36,339 - TSC - DEBUG - [04:44:36] Request complete
2023-12-13 04:44:45,121 - TSC - DEBUG - [04:44:45] Async request returned: received <Response [201]>
2023-12-13 04:44:45,124 - TSC - DEBUG - Response status: <Response [201]>
jacalata commented 8 months ago

This should be fixed by https://github.com/tableau/server-client-python/pull/1300, about to make a new release including that.