{"record":{"id":"0fc5ae407f86c8a0","repo":"googleapis/mcp-toolbox","slug":"failed-to-update-instance-w","errorCode":null,"errorMessage":"failed to update instance: %w","messagePattern":"failed to update instance: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigtable/admin_wrappers.go","lineNumber":56,"sourceCode":"\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)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to delete instance: %w\", err)\n\t}\n\treturn map[string]string{\"status\": \"instance deleted successfully\"}, nil\n}\n\nfunc (s *Source) ListInstances(ctx context.Context) (any, error) {\n\tinstances, err := s.InstanceAdmin.Instances(ctx)\n\tif err != nil {\n\t\tvar partialErr bigtable.ErrPartiallyUnavailable\n\t\tif errors.As(err, &partialErr) {\n\t\t\treturn instances, nil","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigtable/admin_wrappers.go#L38-L74","documentation":"This error wraps a failure from InstanceAdmin.UpdateInstanceWithClusters when applying a new display name (and cluster config) to an existing Bigtable instance. Failures typically stem from the instance not existing, insufficient IAM permissions, or an invalid update payload. The underlying API error is preserved via %w.","triggerScenarios":"Calling UpdateInstance(ctx, instanceId, displayName) for a non-existent instance ID, with a principal lacking bigtable.instances.update (roles/bigtable.admin), or with a config the API rejects (e.g. empty instance ID).","commonSituations":"LLM/tool caller hallucinating an instance name, credentials from the wrong project, attempting to update an instance concurrently deleted by another job, or permission downgrade after rotating service accounts.","solutions":["Confirm the instance exists: `gcloud bigtable instances list` and match the ID exactly.","Ensure the service account has roles/bigtable.admin (update requires admin-level permission).","Check the wrapped status code: NotFound -> fix instance ID; PermissionDenied -> fix IAM; Unavailable -> retry.","Guard against empty instanceId/displayName before calling the API.","Retry with backoff on transient codes (Unavailable, DeadlineExceeded)."],"exampleFix":"// before\nerr := s.InstanceAdmin.UpdateInstanceWithClusters(ctx, conf)\nif err != nil {\n    return nil, fmt.Errorf(\"failed to update instance: %w\", err)\n}\n// after\nif instanceId == \"\" {\n    return nil, fmt.Errorf(\"instanceId is required\")\n}\nerr := s.InstanceAdmin.UpdateInstanceWithClusters(ctx, conf)\nif err != nil {\n    if st, ok := status.FromError(err); ok && st.Code() == codes.NotFound {\n        return nil, fmt.Errorf(\"instance %q not found; cannot update: %w\", instanceId, err)\n    }\n    return nil, fmt.Errorf(\"failed to update instance %q: %w\", instanceId, err)\n}","handlingStrategy":"validation","validationCode":"if instanceId == \"\" || displayName == \"\" {\n    return errors.New(\"both instanceId and displayName are required to update an instance\")\n}\nif _, err := src.GetInstance(ctx, instanceId); err != nil {\n    return fmt.Errorf(\"instance %q does not exist; cannot update: %w\", instanceId, err)\n}","typeGuard":"func isUpdatePermissionError(err error) bool {\n    st, ok := status.FromError(err)\n    return ok && st.Code() == codes.PermissionDenied\n}","tryCatchPattern":"_, err := src.UpdateInstance(ctx, id, name)\nif err != nil {\n    if isNotFound(err) {\n        return fmt.Errorf(\"cannot update %q: instance not found\", id)\n    }\n    if isUpdatePermissionError(err) {\n        return fmt.Errorf(\"needs roles/bigtable.admin to update: %w\", err)\n    }\n    var st *status.Status\n    if errors.As(err, &st) && (st.Code() == codes.Unavailable || st.Code() == codes.DeadlineExceeded) {\n        // safe to retry with backoff\n    }\n    return err\n}","preventionTips":["Validate the instance exists (GetInstance) before attempting updates.","Ensure the principal holds roles/bigtable.admin; viewer roles cannot update.","Do not run updates concurrently with deletes on the same instance.","Retry only transient gRPC codes with exponential backoff."],"tags":["gcp","bigtable","update","grpc"],"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"}