googleapis/mcp-toolbox · error
failed to get materialized view: %w
Error message
failed to get materialized view: %w
What it means
GetMaterializedView wraps errors from InstanceAdmin.MaterializedViewInfo, which fetches details of one materialized view. Failures occur when the view or instance does not exist, permissions are missing, or a transient RPC failure happens. The wrapped error retains the original cause for errors.Is/As checks.
Source
Thrown at internal/sources/bigtable/admin_wrappers.go:240
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)
if err != nil {
return nil, fmt.Errorf("failed to create materialized view: %w", err)
}
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 SDKView on GitHub (pinned to 8cc6e09de2)
Solutions
- Unwrap with status.FromError and handle codes.NotFound by listing available views first
- Verify instanceId/project configuration and that the ID is a materialized view (not a logical view)
- Grant roles/bigtable.viewer or roles/bigtable.admin to the caller's service account
- Retry on transient gRPC codes (Unavailable, DeadlineExceeded)
Example fix
// before: raw NotFound bubbles to the LLM
view, err := s.InstanceAdmin.MaterializedViewInfo(ctx, instanceId, id)
if err != nil { return nil, fmt.Errorf("failed to get materialized view: %w", err) }
// after: friendlier NotFound handling
view, err := s.InstanceAdmin.MaterializedViewInfo(ctx, instanceId, id)
if err != nil {
if st, ok := status.FromError(err); ok && st.Code() == codes.NotFound {
return nil, fmt.Errorf("materialized view %q not found in instance %q", id, instanceId)
}
return nil, fmt.Errorf("failed to get materialized view: %w", err)
} Defensive patterns
Strategy: type-guard
Validate before calling
views, err := src.ListMaterializedViews(ctx, instanceId)
if err != nil { return err }
if !containsMaterializedViewID(views, viewId) {
return fmt.Errorf("materialized view %q not found in %s", viewId, instanceId)
} Type guard
func isNotFound(err error) bool {
st, ok := status.FromError(errors.Unwrap(err))
return ok && st.Code() == codes.NotFound
} Try / catch
view, err := src.GetMaterializedView(ctx, instanceId, viewId)
if err != nil {
if isNotFound(err) {
return nil, fmt.Errorf("materialized view %q not found", viewId)
}
return err
} Prevention
- List materialized views first when the ID may be stale
- Don't confuse logical-view IDs with materialized-view IDs
- Grant roles/bigtable.viewer at minimum for read operations
- Check project/instance configuration if NotFound errors appear unexpectedly
When it happens
Trigger: Calling GetMaterializedView (bigtable_get_materialized_view tool) when: materializedViewId does not exist under instanceId, the instanceId is wrong, the caller lacks bigtable read permissions, or the admin RPC times out.
Common situations: Fetching a view after it was dropped by another process; confusing logical-view IDs with materialized-view IDs; service account missing the Bigtable Viewer/Admin role; project misconfiguration in the source config.
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 create materialized view: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/f3b31089a022c405.
Report an issue: GitHub.