{"record":{"id":"ddb81e1fb45b4000","repo":"googleapis/mcp-toolbox","slug":"failed-to-get-instance-w","errorCode":null,"errorMessage":"failed to get instance: %w","messagePattern":"failed to get instance: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigtable/admin_wrappers.go","lineNumber":29,"sourceCode":"// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage bigtable\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"cloud.google.com/go/bigtable\"\n)\n\nfunc (s *Source) GetInstance(ctx context.Context, instanceId string) (any, error) {\n\tinstance, err := s.InstanceAdmin.InstanceInfo(ctx, instanceId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get instance: %w\", err)\n\t}\n\treturn instance, nil\n}\n\nfunc (s *Source) CreateInstance(ctx context.Context, instanceId, displayName, clusterId, zone string, numNodes int32) (any, error) {\n\tconf := &bigtable.InstanceConf{\n\t\tInstanceId:  instanceId,\n\t\tDisplayName: displayName,\n\t\tClusterId:   clusterId,\n\t\tZone:        zone,\n\t\tNumNodes:    numNodes,\n\t}\n\terr := s.InstanceAdmin.CreateInstance(ctx, conf)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create instance: %w\", err)\n\t}\n\treturn map[string]string{\"status\": \"instance created successfully\"}, nil\n}","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigtable/admin_wrappers.go#L11-L47","documentation":"This error wraps a failure from the Cloud Bigtable admin client's InstanceAdmin.InstanceInfo call when fetching metadata for a Bigtable instance. It means the instance could not be looked up — usually because it does not exist, the caller lacks permission, or the admin client's connection failed. The underlying gRPC/API error is preserved via %w.","triggerScenarios":"Calling GetInstance(ctx, instanceId) where instanceId does not exist in the project, the service account lacks bigtable.instances.get (or bigtable.admin role), the instance name is misspelled, or the underlying gRPC connection to bigtableadmin.googleapis.com fails.","commonSituations":"Typo in instance ID passed by an LLM/tool caller, tool run with credentials from a different project than the instance, IAM principal missing Bigtable Admin/Viewer roles, or instances deleted/renamed between listing and fetch.","solutions":["Verify the instanceId exactly matches an existing instance: `gcloud bigtable instances list`.","Confirm credentials point at the correct project and the principal has bigtable.instances.get (roles/bigtable.viewer or admin).","Check network reachability to bigtableadmin.googleapis.com (proxy/firewall).","Re-create the instance if it was deleted.","Inspect the wrapped inner error for a 404 vs. 403 vs. timeout to target the right fix."],"exampleFix":"// before\ninstance, err := s.InstanceAdmin.InstanceInfo(ctx, instanceId)\nif err != nil {\n    return nil, fmt.Errorf(\"failed to get instance: %w\", err)\n}\n// after\ninstance, err := s.InstanceAdmin.InstanceInfo(ctx, instanceId)\nif err != nil {\n    if st, ok := status.FromError(err); ok && st.Code() == codes.NotFound {\n        return nil, fmt.Errorf(\"instance %q not found in project; check the instance ID: %w\", instanceId, err)\n    }\n    return nil, fmt.Errorf(\"failed to get instance %q: %w\", instanceId, err)\n}","handlingStrategy":"try-catch","validationCode":"adminClient, err := bigtable.NewAdminClient(ctx, project, instanceId)\nif err != nil {\n    return fmt.Errorf(\"cannot reach project %q / instance %q: %w\", project, instanceId, err)\n}\nadminClient.Close()","typeGuard":"func isNotFound(err error) bool {\n    st, ok := status.FromError(err)\n    return ok && st.Code() == codes.NotFound\n}","tryCatchPattern":"inst, err := src.GetInstance(ctx, id)\nif err != nil {\n    var st *status.Status\n    if errors.As(err, &st) && st.Code() == codes.NotFound {\n        return nil, fmt.Errorf(\"instance %q not found; verify the instance ID\", id)\n    }\n    if errors.As(err, &st) && st.Code() == codes.PermissionDenied {\n        return nil, fmt.Errorf(\"missing bigtable.instances.get permission: %w\", err)\n    }\n    return nil, err\n}","preventionTips":["List instances first and validate IDs instead of trusting free-form user/LLM input.","Use the same project for credentials and instance references.","Grant least-privilege roles (roles/bigtable.viewer) explicitly.","Distinguish 404 vs 403 vs timeout when logging to speed diagnosis."],"tags":["gcp","bigtable","grpc","not-found"],"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"}