googleapis/mcp-toolbox · error
failed to delete materialized view: %w
Error message
failed to delete materialized view: %w
What it means
DeleteMaterializedView wraps errors from InstanceAdmin.DeleteMaterializedView. Deletion fails when the view does not exist (NotFound), permissions are missing, or a transient gRPC error occurs. The original error is preserved via %w for programmatic inspection.
Source
Thrown at internal/sources/bigtable/admin_wrappers.go:272
return map[string]string{"status": "materialized view created successfully"}, nil
}
func (s *Source) UpdateMaterializedView(ctx context.Context, instanceId, materializedViewId, query string) (any, error) {
conf := bigtable.MaterializedViewInfo{ // MUST be value per bigtable SDK
MaterializedViewID: materializedViewId,
Query: query,
}
err := s.InstanceAdmin.UpdateMaterializedView(ctx, instanceId, conf)
if err != nil {
return nil, fmt.Errorf("failed to update materialized view: %w", err)
}
return map[string]string{"status": "materialized view updated successfully"}, nil
}
func (s *Source) DeleteMaterializedView(ctx context.Context, instanceId, materializedViewId string) (any, error) {
err := s.InstanceAdmin.DeleteMaterializedView(ctx, instanceId, materializedViewId)
if err != nil {
return nil, fmt.Errorf("failed to delete materialized view: %w", err)
}
return map[string]string{"status": "materialized view deleted successfully"}, nil
}
View on GitHub (pinned to 8cc6e09de2)
Solutions
- Handle codes.NotFound as success for idempotent deletes via status.FromError on the wrapped error
- Confirm the ID belongs to a materialized view, not a logical view
- Grant roles/bigtable.admin or the delete permission to the caller
- Retry on Unavailable/DeadlineExceeded
Example fix
// before: rerun of cleanup fails
err := s.InstanceAdmin.DeleteMaterializedView(ctx, instanceId, id)
// after: idempotent handling
err := s.InstanceAdmin.DeleteMaterializedView(ctx, instanceId, id)
if err != nil && status.Code(err) != codes.NotFound {
return nil, fmt.Errorf("failed to delete materialized view: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
views, err := src.ListMaterializedViews(ctx, instanceId)
if err != nil { return err }
if !containsMaterializedViewID(views, viewId) {
return nil // already absent; treat delete as no-op
} 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.DeleteMaterializedView(ctx, instanceId, viewId)
switch {
case err == nil:
// deleted
case isNotFound(err):
// already deleted: success
default:
return err
} Prevention
- Make cleanup idempotent by treating NotFound as success
- Use the correct tool per namespace: logical views vs materialized views
- Verify delete permission (roles/bigtable.admin) before running teardown scripts
- Add retry with backoff for transient gRPC failures
When it happens
Trigger: Calling DeleteMaterializedView (bigtable_delete_materialized_view tool) when: materializedViewId was already deleted or never existed, the instanceId is wrong, caller lacks delete permission, or the admin RPC fails transiently.
Common situations: Non-idempotent cleanup scripts double-deleting; deleting a logical view ID with the materialized-view tool (separate namespaces); IAM role removals; transient API outages.
Related errors
- failed to list materialized views: %w
- failed to create logical view: %w
- failed to update logical view: %w
- failed to delete logical view: %w
- failed to get materialized view: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/ec0edd0a3cbb5ba6.
Report an issue: GitHub.