You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Google Cloud deployment returns a 500 error when the client secret file is not valid JSON #10673
In the Google Cloud deployment wizard, selecting a client secret file that is not valid JSON makes the "Click here to authenticate yourself to Google" step fail with an internal server error (HTTP 500), instead of saying that the file is invalid.
verify_credentials() in web/pgadmin/misc/cloud/google/__init__.py calls json.load() on the file without handling errors. A file that isn't JSON, isn't UTF-8, or doesn't have the structure of a Google OAuth client secret raises an exception that is not caught. A request without client_secret_file fails the same way, because unquote(None) raises TypeError.
To Reproduce
Start Deploy Cloud PostgreSQL and choose Google Cloud.
Select any file that is not a Google client secret JSON file (e.g. a .sql or text file) as the client secret file.
Click the button to authenticate with Google.
The request returns a 500 error.
Expected behavior
A clear error such as "The client secret file is not a valid Google OAuth client secret JSON file.", returned as a normal bad-request response.
Error message
HTTP 500 Internal Server Error. The server log shows an uncaught json.decoder.JSONDecodeError (or UnicodeDecodeError for a non-UTF-8 file).
Desktop (please complete the following information):
OS: any
pgAdmin version: 9.18 (also current master)
Mode: Desktop and Server
Package type: any
Additional context
Catching ValueError (which covers JSONDecodeError and UnicodeDecodeError), and checking that the expected keys are present, before creating the Google object would fix it. A missing client_secret_file should return the existing "Client secret path not found" error.
Activity