{"record":{"id":"b44343e06c577e4b","repo":"googleapis/mcp-toolbox","slug":"invalid-connection-name-q-project-region-and-i","errorCode":null,"errorMessage":"invalid connection name %q: project, region, and instance must all be non-empty","messagePattern":"invalid connection name %q: project, region, and instance must all be non-empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/cloudsqlconnect/gce.go","lineNumber":38,"sourceCode":"\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\n// the same network name.\nfunc IsSameVPC(sqlVPC, vmVPC string) bool {\n\tsqlNet := ExtractNetworkName(sqlVPC)","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/util/cloudsqlconnect/gce.go#L20-L56","documentation":"After splitting on ':', ParseConnectionName additionally requires every segment (project, region, instance) to be non-empty. A name like 'project::instance' or ':region:instance' has three parts but an empty component, triggering this error.","triggerScenarios":"Passing a connection string with empty segments such as 'project::instance', ':us-central1:inst', or 'project:region:' to ParseConnectionName or ValidateInstanceConnectionName, often from untrimmed or partially interpolated config values.","commonSituations":"Environment variables or config templates with missing placeholders; trailing/leading colons from string concatenation; blank config fields passed straight through.","solutions":["Ensure all three segments are non-empty, e.g. my-project:us-central1:my-instance","Trim whitespace and validate the connection string before passing it in","Log/inspect the source of the string (env var, YAML field) to find which component is empty"],"exampleFix":"// before\nconn := fmt.Sprintf(\"%s:%s:%s\", cfg.Project, cfg.Region, cfg.Instance) // Region empty\n// after\nif cfg.Project == \"\" || cfg.Region == \"\" || cfg.Instance == \"\" {\n    return fmt.Errorf(\"incomplete Cloud SQL config: need project, region, instance\")\n}\nconn := fmt.Sprintf(\"%s:%s:%s\", cfg.Project, cfg.Region, cfg.Instance)","handlingStrategy":"validation","validationCode":"func connNameComplete(conn string) bool {\n    parts := strings.Split(conn, \":\")\n    if len(parts) != 3 { return false }\n    for _, p := range parts { if strings.TrimSpace(p) == \"\" { return false } }\n    return true\n}","typeGuard":null,"tryCatchPattern":"p, r, inst, err := cloudsqlconnect.ParseConnectionName(connName)\nif err != nil {\n    return fmt.Errorf(\"connection name %q has empty parts; check project/region/instance config: %w\", connName, err)\n}","preventionTips":["Fail fast on empty project/region/instance config values before building the name","Trim whitespace from env/config inputs","Use structured config (three fields) instead of a single concatenated string where possible"],"tags":["gcp","cloudsql","configuration","validation"],"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"}