{"record":{"id":"f8b255708e4f9b2a","repo":"googleapis/mcp-toolbox","slug":"failed-to-create-instance-w","errorCode":null,"errorMessage":"failed to create instance: %w","messagePattern":"failed to create instance: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigtable/admin_wrappers.go","lineNumber":44,"sourceCode":"func (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}\n\nfunc (s *Source) UpdateInstance(ctx context.Context, instanceId, displayName string) (any, error) {\n\tconf := &bigtable.InstanceWithClustersConfig{\n\t\tInstanceID:  instanceId,\n\t\tDisplayName: displayName,\n\t}\n\terr := s.InstanceAdmin.UpdateInstanceWithClusters(ctx, conf)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to update instance: %w\", err)\n\t}\n\treturn map[string]string{\"status\": \"instance updated successfully\"}, nil\n}\n\nfunc (s *Source) DeleteInstance(ctx context.Context, instanceId string) (any, error) {\n\terr := s.InstanceAdmin.DeleteInstance(ctx, instanceId)","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigtable/admin_wrappers.go#L26-L62","documentation":"This error wraps a failure from InstanceAdmin.CreateInstance when provisioning a new Bigtable instance with the given display name, cluster, zone, and node count. Common causes are invalid configuration (bad zone, duplicate cluster/instance ID, insufficient nodes), quota limits, or IAM/permission failures. The original API error is preserved via %w.","triggerScenarios":"Calling CreateInstance(ctx, instanceId, displayName, clusterId, zone, numNodes) with an instance ID that already exists, an unsupported/misspelled zone, numNodes below the minimum, exceeding project quota, or lacking roles/bigtable.admin.","commonSituations":"Tool caller inventing a zone name like 'us-central1' instead of 'us-central1-a', duplicate create invoked twice, project hitting the instance/node quota, service account without Bigtable Admin role.","solutions":["Validate the zone is a real Bigtable zone (e.g. us-east1-b): check `gcloud bigtable clusters create --zone` docs or `gcloud compute zones list`.","Ensure the instanceId is unique in the project; check `gcloud bigtable instances list`.","Confirm numNodes meets Bigtable minimums (>=3 for production clusters) and project quota allows it.","Grant the caller roles/bigtable.admin on the project.","Read the wrapped status error — AlreadyExists, InvalidArgument, or ResourceExhausted point to the exact problem."],"exampleFix":"// before\nconf := &bigtable.InstanceConf{ InstanceID: instanceId, DisplayName: displayName, ClusterId: clusterId, Zone: zone, NumNodes: numNodes }\nerr := s.InstanceAdmin.CreateInstance(ctx, conf)\nif err != nil {\n    return nil, fmt.Errorf(\"failed to create instance: %w\", err)\n}\n// after\nif numNodes < 3 {\n    return nil, fmt.Errorf(\"numNodes must be >= 3 for production cluster, got %d\", numNodes)\n}\nerr := s.InstanceAdmin.CreateInstance(ctx, conf)\nif err != nil {\n    if st, ok := status.FromError(err); ok && st.Code() == codes.AlreadyExists {\n        return nil, fmt.Errorf(\"instance %q already exists: %w\", instanceId, err)\n    }\n    return nil, fmt.Errorf(\"failed to create instance %q (zone=%s, nodes=%d): %w\", instanceId, zone, numNodes, err)\n}","handlingStrategy":"validation","validationCode":"zones := map[string]bool{\"us-east1-b\": true, \"us-central1-a\": true /* populate from gcloud compute zones list */}\nif instanceId == \"\" || clusterId == \"\" || !zones[zone] {\n    return fmt.Errorf(\"invalid create-instance params: id=%q cluster=%q zone=%q\", instanceId, clusterId, zone)\n}\nif numNodes < 3 {\n    return fmt.Errorf(\"numNodes must be >= 3, got %d\", numNodes)\n}","typeGuard":"func validInstanceConf(conf *bigtable.InstanceConf) error {\n    if conf == nil || conf.InstanceID == \"\" || conf.ClusterId == \"\" || conf.Zone == \"\" {\n        return errors.New(\"instanceId, clusterId and zone are required\")\n    }\n    if conf.NumNodes < 3 {\n        return fmt.Errorf(\"numNodes must be >= 3, got %d\", conf.NumNodes)\n    }\n    return nil\n}","tryCatchPattern":"_, err := src.CreateInstance(ctx, id, name, cluster, zone, nodes)\nif err != nil {\n    if st, ok := status.FromError(err); ok {\n        switch st.Code() {\n        case codes.AlreadyExists:\n            return fmt.Errorf(\"instance %q already exists\", id)\n        case codes.ResourceExhausted:\n            return fmt.Errorf(\"quota exceeded; request quota increase\")\n        case codes.PermissionDenied:\n            return fmt.Errorf(\"requires roles/bigtable.admin: %w\", err)\n        }\n    }\n    return err\n}","preventionTips":["Validate zone names against Bigtable-supported zones before calling create.","Check existing instances to avoid AlreadyExists on double invocation.","Verify project quota for instances and nodes in advance.","Use a service account with roles/bigtable.admin for provisioning tools.","Retry only transient codes (Unavailable, DeadlineExceeded) with backoff."],"tags":["gcp","bigtable","provisioning","quota"],"backgroundTag":"cloud-resource-provision-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"}