{"record":{"id":"22cd4beb9e52ae30","repo":"googleapis/mcp-toolbox","slug":"error-listing-instances-w","errorCode":null,"errorMessage":"error listing instances: %w","messagePattern":"error listing instances: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/cloudsqladmin/cloud_sql_admin.go","lineNumber":281,"sourceCode":"\tfor _, item := range resp.Items {\n\t\tdatabases = append(databases, databaseInfo{\n\t\t\tName:      item.Name,\n\t\t\tCharset:   item.Charset,\n\t\t\tCollation: item.Collation,\n\t\t})\n\t}\n\treturn databases, nil\n}\n\nfunc (s *Source) ListInstance(ctx context.Context, project, accessToken string) (any, error) {\n\tservice, err := s.GetService(ctx, accessToken)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := service.Instances.List(project).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing instances: %w\", err)\n\t}\n\n\tif resp.Items == nil {\n\t\treturn []any{}, nil\n\t}\n\n\ttype instanceInfo struct {\n\t\tName         string `json:\"name\"`\n\t\tInstanceType string `json:\"instanceType\"`\n\t}\n\n\tvar instances []instanceInfo\n\tfor _, item := range resp.Items {\n\t\tinstances = append(instances, instanceInfo{\n\t\t\tName:         item.Name,\n\t\t\tInstanceType: item.InstanceType,\n\t\t})\n\t}","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudsqladmin/cloud_sql_admin.go#L263-L299","documentation":"Thrown in ListInstance when the sqladmin Instances.List call (projects.instances.list) fails. Listing all Cloud SQL instances in a project returned an API error before the empty-items normalization.","triggerScenarios":"Calling the list_instances tool with an invalid project ID, a principal lacking cloudsql.instances.list permission, or during a transient Cloud SQL API outage.","commonSituations":"Misconfigured project ID in the tool arguments; service account without roles/cloudsql.viewer; org policy or API not enabled; rate limiting (429) on very active projects.","solutions":["Verify the project ID is correct and the Cloud SQL Admin API is enabled.","Grant roles/cloudsql.viewer to the calling principal.","Retry with backoff on 429/5xx responses.","Inspect the wrapped googleapi.Error code and message.","Confirm no VPC Service Controls perimeter is blocking sqladmin.googleapis.com."],"exampleFix":"null","handlingStrategy":"retry","validationCode":"if project == \"\" {\n    return fmt.Errorf(\"project is required to list instances\")\n}\n// confirm project is valid\nif _, err := resourcemanagerService.Projects.Get(project).Do(); err != nil {\n    return fmt.Errorf(\"invalid or inaccessible project %q: %w\", project, err)\n}","typeGuard":"func isRateLimited(err error) bool {\n    var gerr *googleapi.Error\n    return errors.As(err, &gerr) && gerr.Code == 429\n}","tryCatchPattern":"var out any\nvar err error\nbackoff := time.Second\nfor attempt := 0; attempt < 4; attempt++ {\n    out, err = src.ListInstance(ctx, project, token)\n    if err == nil || !isRateLimited(err) {\n        break\n    }\n    time.Sleep(backoff)\n    backoff *= 2\n}\nif err != nil {\n    return fmt.Errorf(\"list instances failed: %w\", err)\n}","preventionTips":["Back off exponentially on 429 rate-limit errors.","Verify project ID and that the Cloud SQL Admin API is enabled.","Grant roles/cloudsql.viewer as the minimum role.","Watch for VPC Service Controls rejections if operating inside a perimeter."],"tags":["gcp","cloud-sql","api-error","listing"],"backgroundTag":"cloudsql-api-request-failed","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"}