{"record":{"id":"54d34a11460eb33d","repo":"googleapis/mcp-toolbox","slug":"error-getting-instance-w","errorCode":null,"errorMessage":"error getting instance: %w","messagePattern":"error getting instance: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/cloudsqladmin/cloud_sql_admin.go","lineNumber":236,"sourceCode":"\t}\n\n\tresp, err := service.Users.Insert(project, instance, &user).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating user: %w\", err)\n\t}\n\n\treturn resp, nil\n}\n\nfunc (s *Source) GetInstance(ctx context.Context, projectId, instanceId, 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.Get(projectId, instanceId).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting instance: %w\", err)\n\t}\n\treturn resp, nil\n}\n\nfunc (s *Source) ListDatabase(ctx context.Context, project, instance, 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.Databases.List(project, instance).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing databases: %w\", err)\n\t}\n\n\tif resp.Items == nil {\n\t\treturn []any{}, nil\n\t}","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudsqladmin/cloud_sql_admin.go#L218-L254","documentation":"Thrown in GetInstance when the sqladmin Instances.Get call (projects.instances.get) fails. The lookup of a Cloud SQL instance's details returned an API error.","triggerScenarios":"Calling the get_instance tool with an instance ID that does not exist in the project, a misspelled project ID, or when the caller lacks cloudsql.instances.get permission.","commonSituations":"Wrong project selected (instance lives in another project); typo in instance name; workload identity/service account missing Cloud SQL Viewer role; API disabled in the project.","solutions":["Verify the instance ID with the list_instances tool or `gcloud sql instances list --project <project>`.","Correct the project ID and re-run.","Grant roles/cloudsql.viewer (or admin) to the calling principal.","Enable sqladmin.googleapis.com in the project if not enabled.","Inspect the wrapped googleapi.Error: 404 = not found, 403 = permission."],"exampleFix":"// before\nGetInstance(ctx, \"my-proj\", \"my-instnce\", token) // typo\n// after\nGetInstance(ctx, \"my-proj\", \"my-instance\", token)","handlingStrategy":"type-guard","validationCode":"if projectId == \"\" || instanceId == \"\" {\n    return fmt.Errorf(\"projectId and instanceId are required\")\n}\nif err := ensureAPIEnabled(ctx, projectId, \"sqladmin.googleapis.com\"); err != nil {\n    return err\n}","typeGuard":"func isNotFoundErr(err error) bool {\n    var gerr *googleapi.Error\n    return errors.As(err, &gerr) && gerr.Code == http.StatusNotFound\n}","tryCatchPattern":"out, err := src.GetInstance(ctx, projectId, instanceId, token)\nif err != nil {\n    if isNotFoundErr(err) {\n        return fmt.Errorf(\"instance %q not found in project %q; check names with list_instances\", instanceId, projectId)\n    }\n    return fmt.Errorf(\"get instance failed: %w\", err)\n}","preventionTips":["Cross-check instance names with list_instances before direct lookups.","Confirm the correct project ID is configured in the source.","Grant roles/cloudsql.viewer as the minimum IAM role.","Enable the Cloud SQL Admin API in the target project."],"tags":["gcp","cloud-sql","api-error","lookup"],"backgroundTag":"resource-not-found","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"}