Closed darttie closed 1 month ago
I noticed this intermittently starting on 2024-08-07 around 15:00 UTC. I was getting it on fetch_sheet_metadata()
venv/lib/python3.9/site-packages/gspread/http_client.py", line 303, in fetch_sheet_metadata -> requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Hi, thank you for raising this issue, I believe this is a problem with Google servers, we receive a valid JSON error message on every error for as many years as I can remember on this project.
possibly it could be a network error too where you don't receive the error response (the connection closes early, etc).
In order to investigate your issue and help further similar situations and possibly provide a solution to #1491 we can change the way we handle errors to:
Response
objecttext
payload (which could be empty, we don't know)Dict
object with response_code=-1
and the error message with whatever text we extractedThis way we don't fail because of weird/empty/malformed JSON response We still can print/return some error in the same format we do all over the project We can solve the issue with the mentioned PR above that returns some HTML error message.
@alifeee how do you feel about this ?
this has been fixed with #1510 and the fix will be included in the next release (which should be in the coming time, see #1516)
hi all
a new release 6.1.3
has been released (on github) (on PyPi) which contains a fix for this issue
we now catch the non-JSON error and turn it into a GSpreadException
which should be easier to catch and find out what went wrong with the request
see more context here: https://github.com/burnash/gspread/pull/1510
Describe the bug My code called sh.sheet1.batch_get([gsrange], Dimension.cols) which sends request to google sheets. It looks like some error response was returned, but the following exception was raised when APIError was trying to be constructed:
To Reproduce Unfortunately the bug prevents me from knowing what error actually happened. Usually this step succeeds, but once it has failed.
Expected behavior Correct APIError is returned
Environment info: