`getConnectionOptionsFromUri` fails for Cloud SQL Unix-socket URIs on mysql:// and mariadb://
** 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:
- Unescaped colons in the Cloud SQL instance name (
project:region:instance) causingnew URL()to throwInvalid URL. - The
?host=/cloudsql/...query-param convention, whichURLhas 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:
- Provision a Cloud SQL MySQL or MariaDB instance and connect over the standard Unix socket (
/cloudsql/<PROJECT>:<REGION>:<INSTANCE>). - Configure
DatabaseSessionServicewith a socket-form session URI, e.g.mysql://u:p@/cloudsql/proj:r:inst/db(or the?host=/cloudsql/...variant). - Run
getConnectionOptionsFromUri()on that URI. - 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/adk1.6.0+ (same as #799)
Additional context
- Related: #799, #869 (Postgres-only fix; this issue covers the remaining MySQL/MariaDB gap)
- Suggested approach: split
parsePostgresSocketUriinto a scheme-agnosticparseSocketUri(uri)returning{host, user, password, dbName, schema, port}, and let each driver's call site decidehostvssocketPath.
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.