{"record":{"id":"65ef617927b0d893","repo":"googleapis/mcp-toolbox","slug":"unable-to-create-pool-w-65ef61","errorCode":null,"errorMessage":"unable to create pool: %w","messagePattern":"unable to create pool: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/sources/cloudsqlmysql/cloud_sql_mysql.go","lineNumber":74,"sourceCode":"\tProject      string         `yaml:\"project\" validate:\"required\"`\n\tRegion       string         `yaml:\"region\" validate:\"required\"`\n\tInstance     string         `yaml:\"instance\" validate:\"required\"`\n\tIPType       sources.IPType `yaml:\"ipType\"`\n\tUser         string         `yaml:\"user\"`\n\tPassword     string         `yaml:\"password\"`\n\tDatabase     string         `yaml:\"database\"`\n\tReadOnly     bool           `yaml:\"readOnly\"`\n\tSQLCommenter *bool          `yaml:\"sqlCommenter\"`\n}\n\nfunc (r Config) SourceConfigType() string {\n\treturn SourceType\n}\n\nfunc (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {\n\tpool, err := initCloudSQLMySQLConnectionPool(ctx, tracer, r.Name, r.Project, r.Region, r.Instance, r.IPType.String(), r.User, r.Password, r.Database, r.ReadOnly)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create pool: %w\", err)\n\t}\n\n\terr = pool.PingContext(ctx)\n\tif err != nil {\n\t\tpool.Close()\n\t\treturn nil, fmt.Errorf(\"unable to connect successfully: %w\", err)\n\t}\n\n\ts := &Source{\n\t\tConfig: r,\n\t\tPool:   pool,\n\t}\n\treturn s, nil\n}\n\nvar _ sources.Source = &Source{}\n\ntype Source struct {","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudsqlmysql/cloud_sql_mysql.go#L56-L92","documentation":"This error is returned by the cloud-sql-mysql source's Initialize when initCloudSQLMySQLConnectionPool fails to build the MySQL connection pool. It wraps earlier failures: resolving IAM principal email from ADC, invalid ipType options, driver registration failure, or sql.Open errors. Note sql.Open rarely fails eagerly — most real problems surface at the subsequent PingContext step (a separate 'unable to connect successfully' error).","triggerScenarios":"Config.Initialize for a source of type 'cloud-sql-mysql' — password provided without a username, GetIAMPrincipalEmailFromADC fails (no Application Default Credentials or missing Cloud SQL scopes), sources.GetCloudSQLOpts receives an invalid ipType, mysql.RegisterDriver fails, or sql.Open gets a malformed DSN.","commonSituations":"Setting readOnly:true with an invalid iam principal, ADC not configured (GOOGLE_APPLICATION_CREDENTIALS unset) when relying on IAM auth, password set but user left empty (explicitly rejected), invalid ipType value other than public/private, duplicate driver registration edge cases.","solutions":["If using IAM auth (no user/password), ensure ADC is set up (GOOGLE_APPLICATION_CREDENTIALS or gcloud auth application-default login)","Provide BOTH user and password, or neither — a password without a username is rejected","Set ipType to a valid value (public or private)","Check the wrapped error to see which pool-init step failed (config, driver registration, or sql.Open)","Ensure the Cloud SQL Admin API is enabled and the caller has cloudsql.instances.get permission"],"exampleFix":"// before\nuser: \"\"\npassword: \"secret\"  # password without username is rejected\n// after\nuser: \"myuser\"\npassword: \"secret\"  # or remove both to use IAM auth via ADC","handlingStrategy":"validation","validationCode":"// Before starting the toolbox, verify ADC and instance coordinates\ncmd := exec.Command(\"gcloud\", \"sql\", \"instances\", \"describe\", instance,\n    \"--project\", project, \"--format\", \"value(state)\")\nout, err := cmd.Output()\n// out == \"RUNNABLE\" means the instance is up; also ensure IAM auth users have\n// cloudsql.instances.login permission when omitting user/password","typeGuard":null,"tryCatchPattern":"src, err := cfg.Initialize(ctx, tracer)\nif err != nil {\n    if strings.Contains(err.Error(), \"unable to create pool\") {\n        return fmt.Errorf(\"check ADC/credentials and pool config: %w\", err)\n    }\n    return err\n}","preventionTips":["Set GOOGLE_APPLICATION_CREDENTIALS or run `gcloud auth application-default login` when using IAM auth","Always supply user and password together, or neither — never only a password","Use only valid ipType values (public/private)","Grant the caller's service account roles/cloudsql.client before startup"],"tags":["cloudsql","mysql","database","connection-pool","startup"],"backgroundTag":"cloud-sql-connection-failure","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}