open_by_url silently failing
See original GitHub issueI recently upgraded from gspread 0.6.2 to 3.1.0. According to the docs, open_by_url
should raise an exception if the spreadsheet is not found; I noticed that it does not. Instead, the command runs without error and appears to get set to spreadsheet instance which has the following output.
(Pdb) ss = self._client.open_by_url('http://docs.google.com/spreadsheets/d/foobar')
(Pdb) print(ss)
*** gspread.exceptions.APIError: {
"error": {
"code": 404,
"message": "Requested entity was not found.",
"status": "NOT_FOUND"
}
}
Here, the ss
variable is set showing that an exception was never raised. This is causing my exception handler for exponential backoff to be completely bypassed.
Environment Info
Operating System: Mac OSX 10.13.6 High Sierra Python version: 3.7.1 gspread version: 3.1.0
Steps to reproduce
- c = gspread.authorize(self._credentials)
- ss = c.open_by_url(‘http://docs.google.com/spreadsheets/d/foobar’)
Observations
- The
ss
variable is getting set showing that no exception was raised. - The output of
ss
shows an exception but it was never raised:
(Pdb) print(ss)
*** gspread.exceptions.APIError: {
"error": {
"code": 404,
"message": "Requested entity was not found.",
"status": "NOT_FOUND"
}
}
- Note that it would be nice if
open_by_key
raised an exception as well (it too does not)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
SpreadsheetApp.openByUrl and openById give errors
This error is due to a change Google recently rolled out prohibiting the use of SpreadsheetApp.openByUrl() (or SpreadsheetApp.openById() in custom functions ...
Read more >Script "fails" without any logs or errors - Google Groups
I have a script that, after switching to the new Scripts experience, runs for about 5 seconds, and then finishes /fails, but without...
Read more >Unexpected "authorization is required" error from google.script ...
does anyone have a code workaround for this even? a way to detect that the user is going to fail the request. silently...
Read more >Import online excel file in google spreadsheet - Edureka
... catch(e){} // fail silently if no such folder id exists in Drive ... openByUrl("https://docs.google.com/document/d/[My document ...
Read more >Re: How to Integrate Google Apps Script & Trigger
Executing a DeepLink action from an Email Silently Tips & Tricks. [STRUCTURE AND THE APP BUILD] I will try to explain briefly but...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am experiencing the same issue for
open_by_key
on version 3.2.0. Is there a fix for this?I just checked the source code, this thing should be easy to fix
In
0.6.2
, this is whySpreadsheetNotFound
can be raised: https://github.com/burnash/gspread/blob/6b1bb1ef6db8b318e3da5053ab173add853d3fe0/gspread/client.py#L106In
3.2.0
, just add thetry-except
block back: https://github.com/burnash/gspread/blob/bcd95f751b49e8392dd65dde0cab2a2f0a46b497/gspread/client.py#L145