googleapis/mcp-toolbox · error
failed to delete logical view: %w
Error message
failed to delete logical view: %w
What it means
DeleteLogicalView wraps errors from InstanceAdmin.DeleteLogicalView. Deletion fails if the logical view does not exist (NotFound), permissions are missing, or a transient gRPC error occurs. The raw API error is preserved via %w.
Source
Thrown at internal/sources/bigtable/admin_wrappers.go:232
return map[string]string{"status": "logical view created successfully"}, nil
}
func (s *Source) UpdateLogicalView(ctx context.Context, instanceId, logicalViewId, query string) (any, error) {
conf := bigtable.LogicalViewInfo{ // MUST be value per bigtable SDK
LogicalViewID: logicalViewId,
Query: query,
}
err := s.InstanceAdmin.UpdateLogicalView(ctx, instanceId, conf)
if err != nil {
return nil, fmt.Errorf("failed to update logical view: %w", err)
}
return map[string]string{"status": "logical view updated successfully"}, nil
}
func (s *Source) DeleteLogicalView(ctx context.Context, instanceId, logicalViewId string) (any, error) {
err := s.InstanceAdmin.DeleteLogicalView(ctx, instanceId, logicalViewId)
if err != nil {
return nil, fmt.Errorf("failed to delete logical view: %w", err)
}
return map[string]string{"status": "logical view deleted successfully"}, nil
}
func (s *Source) GetMaterializedView(ctx context.Context, instanceId, materializedViewId string) (any, error) {
view, err := s.InstanceAdmin.MaterializedViewInfo(ctx, instanceId, materializedViewId)
if err != nil {
return nil, fmt.Errorf("failed to get materialized view: %w", err)
}
return view, nil
}
func (s *Source) CreateMaterializedView(ctx context.Context, instanceId, materializedViewId, query string) (any, error) {
conf := &bigtable.MaterializedViewInfo{
MaterializedViewID: materializedViewId,
Query: query,
}
err := s.InstanceAdmin.CreateMaterializedView(ctx, instanceId, conf)View on GitHub (pinned to 8cc6e09de2)
Solutions
- Treat codes.NotFound as success (idempotent delete) using errors.As/status.FromError on the wrapped error
- Confirm the correct ID type: logical views and materialized views live in separate namespaces
- Grant roles/bigtable.admin or bigtable.views.delete to the caller
- Retry on Unavailable/DeadlineExceeded transient codes
Example fix
// before: non-idempotent delete breaks cleanup scripts
err := s.InstanceAdmin.DeleteLogicalView(ctx, instanceId, id)
if err != nil { return nil, fmt.Errorf("failed to delete logical view: %w", err) }
// after: tolerate already-deleted
err := s.InstanceAdmin.DeleteLogicalView(ctx, instanceId, id)
if err != nil {
if st, ok := status.FromError(err); ok && st.Code() == codes.NotFound {
return map[string]string{"status": "logical view already deleted"}, nil
}
return nil, fmt.Errorf("failed to delete logical view: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
views, err := src.ListLogicalViews(ctx, instanceId)
if err != nil { return err }
if !containsViewID(views, viewId) {
return nil // nothing to delete; treat as success
} Type guard
func isNotFound(err error) bool {
st, ok := status.FromError(errors.Unwrap(err))
return ok && st.Code() == codes.NotFound
} Try / catch
res, err := src.DeleteLogicalView(ctx, instanceId, viewId)
switch {
case err == nil:
// deleted
case isNotFound(err):
// already gone: treat as success (idempotent delete)
default:
return err
} Prevention
- Write delete/cleanup scripts to treat NotFound as success so reruns are idempotent
- Don't mix logical-view and materialized-view IDs — they are separate namespaces
- Verify the view still exists if another process may have deleted it
- Retry transient codes (Unavailable, DeadlineExceeded) with backoff
When it happens
Trigger: Calling DeleteLogicalView (bigtable_delete_logical_view tool) when: logicalViewId was already deleted or never existed, caller lacks bigtable.views.delete permission, or the InstanceAdmin RPC fails due to network/timeout.
Common situations: Double-delete in cleanup scripts expecting idempotency; deleting a logical view that was actually a materialized view (wrong ID type); IAM changes; regional API outage.
Related errors
- failed to list materialized views: %w
- failed to create logical view: %w
- failed to update logical view: %w
- failed to get materialized view: %w
- failed to create materialized view: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/5dc612e6b28f2d4e.
Report an issue: GitHub.