{"record":{"id":"2e3bb4f26a1c0542","repo":"googleapis/mcp-toolbox","slug":"invalid-connection-name-format-q-expected-projec","errorCode":null,"errorMessage":"invalid connection name format %q: expected project:region:instance","messagePattern":"invalid connection name format %q: expected project:region:instance","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/cloudsqlconnect/gce.go","lineNumber":35,"sourceCode":"import (\n\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\t\"sync\"\n\n\t\"golang.org/x/oauth2\"\n\t\"google.golang.org/api/compute/v1\"\n\t\"google.golang.org/api/option\"\n\tsqladmin \"google.golang.org/api/sqladmin/v1\"\n)\n\n// ParseConnectionName splits a Cloud SQL instance connection name\n// (\"project:region:instance\") into its three components, rejecting any input\n// that doesn't have exactly three non-empty parts.\nfunc ParseConnectionName(connName string) (project, region, instance string, err error) {\n\tparts := strings.Split(connName, \":\")\n\tif len(parts) != 3 {\n\t\treturn \"\", \"\", \"\", fmt.Errorf(\"invalid connection name format %q: expected project:region:instance\", connName)\n\t}\n\tif parts[0] == \"\" || parts[1] == \"\" || parts[2] == \"\" {\n\t\treturn \"\", \"\", \"\", fmt.Errorf(\"invalid connection name %q: project, region, and instance must all be non-empty\", connName)\n\t}\n\treturn parts[0], parts[1], parts[2], nil\n}\n\n// ExtractNetworkName pulls the trailing element off a fully-qualified network\n// or subnetwork resource path. Idempotent for inputs that are already a name.\nfunc ExtractNetworkName(path string) string {\n\tidx := strings.LastIndex(path, \"/\")\n\tif idx == -1 {\n\t\treturn path\n\t}\n\treturn path[idx+1:]\n}\n\n// IsSameVPC reports whether the Cloud SQL VPC and the GCE VM VPC resolve to","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/util/cloudsqlconnect/gce.go#L17-L53","documentation":"ParseConnectionName splits a Cloud SQL instance connection name of the form project:region:instance. The string must contain exactly three colon-separated non-empty parts; anything else (wrong number of colons) yields this error.","triggerScenarios":"Passing a connection name with fewer or more than three colon-separated segments, e.g. 'my-project~my-region~my-instance' (domain-scoped projects use ~), 'project:instance', or an empty string, to ParseConnectionName or ValidateInstanceConnectionName.","commonSituations":"Using the MySQL-style '~' separator instead of ':'; omitting the region; passing a database name or host instead of the connection name; domain-scoped project IDs ('example.com:my-project') shifting the segment count.","solutions":["Provide the full connection name as project:region:instance, e.g. my-project:us-central1:my-instance","Copy the connection name verbatim from the Cloud SQL console / 'gcloud sql instances describe'","If the project is domain-scoped, use the short project ID or adjust parsing since colons in the project change segment count"],"exampleFix":"// before\nconn := \"my-project~us-central1~my-instance\"\np, r, i, err := cloudsqlconnect.ParseConnectionName(conn)\n// after\nconn := \"my-project:us-central1:my-instance\"\np, r, i, err := cloudsqlconnect.ParseConnectionName(conn)","handlingStrategy":"validation","validationCode":"func validConnName(conn string) bool {\n    parts := strings.Split(conn, \":\")\n    return len(parts) == 3 && parts[0] != \"\" && parts[1] != \"\" && parts[2] != \"\"\n}\nif !validConnName(connName) {\n    return fmt.Errorf(\"bad Cloud SQL connection name: %q\", connName)\n}","typeGuard":null,"tryCatchPattern":"p, r, inst, err := cloudsqlconnect.ParseConnectionName(connName)\nif err != nil {\n    return fmt.Errorf(\"check connection name %q: must be project:region:instance: %w\", connName, err)\n}","preventionTips":["Copy connection names verbatim from Cloud SQL console or gcloud output","Never hand-build connection names with '~' separators","Assert config values with a format check before use"],"tags":["gcp","cloudsql","configuration","string-parsing"],"backgroundTag":"invalid-connection-name-format","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"}