adk-js icon indicating copy to clipboard operation
adk-js copied to clipboard

`getConnectionOptionsFromUri` fails for Cloud SQL Unix-socket URIs on mysql:// and mariadb://

Open AnupamKumar-1 opened this issue 2 months ago • 2 comments

** Please make sure you read the contribution guide and file the issues in the right place. ** Contribution guide.

Describe the bug getConnectionOptionsFromUri (core/src/sessions/db/operations.ts) forwards mysql:// and mariadb:// URIs straight through as clientUrl with no Unix-socket handling. #799 / #869 fixed this for postgres:///postgresql://, but the identical bug is still live on mysql:// and mariadb://, since Cloud SQL for MySQL uses the same /cloudsql/PROJECT:REGION:INSTANCE socket convention:

​ts if (uri.startsWith('mysql://')) { ... return { entities: ENTITIES, clientUrl: uri, driver: MySqlDriver }; } if (uri.startsWith('mariadb://')) { ... return { entities: ENTITIES, clientUrl: uri, driver: MariaDbDriver }; } ​

Per the root-cause clarification added to #799, the failure isn't a percent-decoding gap — it's:

  1. Unescaped colons in the Cloud SQL instance name (project:region:instance) causing new URL() to throw Invalid URL.
  2. The ?host=/cloudsql/... query-param convention, which URL has no concept of.

Additionally, unlike Postgres, mysql2 and mariadb don't treat a /-prefixed host as a domain socket — they use a separate socketPath option (mysql2/lib/connection_config.js:52, mariadb/lib/config/connection-options.js:104), so a straight port of the Postgres fix won't work; the parsed socket path needs to map to socketPath, not host, at the call site.

To Reproduce Steps to reproduce the behavior:

  1. Provision a Cloud SQL MySQL or MariaDB instance and connect over the standard Unix socket (/cloudsql/<PROJECT>:<REGION>:<INSTANCE>).
  2. Configure DatabaseSessionService with a socket-form session URI, e.g. mysql://u:p@/cloudsql/proj:r:inst/db (or the ?host=/cloudsql/... variant).
  3. Run getConnectionOptionsFromUri() on that URI.
  4. See error — Invalid URL, or the socket path gets sent to DNS as a hostname.

Expected behavior The socket-form URI should resolve to the Unix socket path (via socketPath) and connect, matching the behavior now fixed for postgres:///postgresql:// in #869.

Screenshots N/A

Desktop (please complete the following information):

  • OS: N/A (server-side / Cloud Run)
  • TS version/environment: same as affected by #799
  • ADK version(see maven dependency): @google/adk 1.6.0+ (same as #799)

Additional context

  • Related: #799, #869 (Postgres-only fix; this issue covers the remaining MySQL/MariaDB gap)
  • Suggested approach: split parsePostgresSocketUri into a scheme-agnostic parseSocketUri(uri) returning {host, user, password, dbName, schema, port}, and let each driver's call site decide host vs socketPath.

AnupamKumar-1 avatar Sep 08 '26 07:09 AnupamKumar-1

Hi @AnupamKumar-1, Thank you for reporting the issue and submitting a PR to fix it. We have reproduced the issue, and the PR will be reviewed. Thank you for your patience and understanding.

Varun-S10 avatar Sep 09 '26 08:09 Varun-S10

Are you satisfied with the resolution of your issue? Yes No

github-actions[bot] avatar Sep 10 '26 19:09 github-actions[bot]