-
Notifications
You must be signed in to change notification settings - Fork 948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception requests.exceptions.JSONDecodeError is raised in APIError constructor #1504
Comments
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 |
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:
This way we don't fail because of weird/empty/malformed JSON response @alifeee how do you feel about this ? |
Possibly we encountered an error while parsing the API error JSON, like connection closes early etc and the received JSON is invalid. Better handle such scenario and build a valid error Dict to keep the exception stack flow running and raise this message to the application. extract the returned text so if we any bit of valid information at least we can pass that to the application. This could be helpfull to if we add calls to the API made for web browser that returns HTML error message, it will fail to decode the recieved error and raise a proper error. closes #1504 Signed-off-by: Alexandre Lavigne <[email protected]>
Possibly we encountered an error while parsing the API error JSON, like connection closes early etc and the received JSON is invalid. Better handle such scenario and build a valid error Dict to keep the exception stack flow running and raise this message to the application. extract the returned text so if we any bit of valid information at least we can pass that to the application. This could be helpfull to if we add calls to the API made for web browser that returns HTML error message, it will fail to decode the recieved error and raise a proper error. closes #1504 Signed-off-by: Alexandre Lavigne <[email protected]>
Possibly we encountered an error while parsing the API error JSON, like connection closes early etc and the received JSON is invalid. Better handle such scenario and build a valid error Dict to keep the exception stack flow running and raise this message to the application. extract the returned text so if we any bit of valid information at least we can pass that to the application. This could be helpfull to if we add calls to the API made for web browser that returns HTML error message, it will fail to decode the recieved error and raise a proper error. closes #1504 Signed-off-by: Alexandre Lavigne <[email protected]> (cherry picked from commit db59084)
Possibly we encountered an error while parsing the API error JSON, like connection closes early etc and the received JSON is invalid. Better handle such scenario and build a valid error Dict to keep the exception stack flow running and raise this message to the application. extract the returned text so if we any bit of valid information at least we can pass that to the application. This could be helpfull to if we add calls to the API made for web browser that returns HTML error message, it will fail to decode the recieved error and raise a proper error. closes #1504 Signed-off-by: Alexandre Lavigne <[email protected]> (cherry picked from commit db59084)
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:
The text was updated successfully, but these errors were encountered: