Skip to content

Google Cloud deployment returns a 500 error when the client secret file is not valid JSON #10673

Open

Description

@asheshv

Describe the bug

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

  1. Start Deploy Cloud PostgreSQL and choose Google Cloud.
  2. Select any file that is not a Google client secret JSON file (e.g. a .sql or text file) as the client secret file.
  3. Click the button to authenticate with Google.
  4. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions