googleapis/mcp-toolbox · error

failed to get logical view: %w

Error message

failed to get logical view: %w

What it means

This error wraps failures from the Bigtable InstanceAdmin client's LogicalViewInfo call in Source.GetLogicalView. The library wraps the underlying error with fmt.Errorf("failed to get logical view: %w", err); the real gRPC cause (view not found, permissions, network) stays in the wrapped chain.

Source

Thrown at internal/sources/bigtable/admin_wrappers.go:184

}

func (s *Source) UpdateTable(ctx context.Context, tableId string, disableChangeStream bool) (any, error) {
	var err error
	if disableChangeStream {
		err = s.Admin.UpdateTableDisableChangeStream(ctx, tableId)
	} else {
		err = s.Admin.UpdateTableWithChangeStream(ctx, tableId, 24*time.Hour)
	}
	if err != nil {
		return nil, fmt.Errorf("failed to update table: %w", err)
	}
	return map[string]string{"status": "table updated successfully"}, nil
}

func (s *Source) GetLogicalView(ctx context.Context, instanceId, logicalViewId string) (any, error) {
	view, err := s.InstanceAdmin.LogicalViewInfo(ctx, instanceId, logicalViewId)
	if err != nil {
		return nil, fmt.Errorf("failed to get logical view: %w", err)
	}
	return view, nil
}

func (s *Source) ListLogicalViews(ctx context.Context, instanceId string) (any, error) {
	views, err := s.InstanceAdmin.LogicalViews(ctx, instanceId)
	if err != nil {
		return nil, fmt.Errorf("failed to list logical views: %w", err)
	}
	return views, nil
}

func (s *Source) ListMaterializedViews(ctx context.Context, instanceId string) (any, error) {
	views, err := s.InstanceAdmin.MaterializedViews(ctx, instanceId)
	if err != nil {
		return nil, fmt.Errorf("failed to list materialized views: %w", err)
	}
	return views, nil

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. List logical views first (list_logical_views) to confirm the exact view ID and instance.
  2. Check IAM for view-read permissions (roles/bigtable.admin or appropriate bigtable.views.* grants).
  3. Upgrade cloud.google.com/go/bigtable if the API is unsupported or the server returns Unimplemented.
  4. Retry transient gRPC errors with backoff; inspect status.Code(err) for the specific cause.

Example fix

// before
view, err := s.InstanceAdmin.LogicalViewInfo(ctx, instanceId, logicalViewId)
// after: pre-check existence via list
views, _ := s.InstanceAdmin.LogicalViews(ctx, instanceId)
if !containsView(views, logicalViewId) {
    return nil, fmt.Errorf("logical view %q not found in instance %q", logicalViewId, instanceId)
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: check the view exists before fetching details
views, err := instanceAdmin.LogicalViews(ctx, instanceId)
if err != nil {
    return fmt.Errorf("cannot enumerate views: %w", err)
}
found := false
for _, v := range views {
    if v.ID == logicalViewId { found = true }
}
if !found {
    return fmt.Errorf("logical view %q not found in %q", logicalViewId, instanceId)
}

Type guard

func isViewNotFound(err error) bool {
    return status.Code(err) == codes.NotFound
}

Try / catch

view, err := src.GetLogicalView(ctx, instanceId, viewId)
if err != nil {
    if status.Code(err) == codes.NotFound {
        return fmt.Errorf("logical view %q does not exist", viewId)
    }
    return fmt.Errorf("get logical view: %w", err)
}

Prevention

When it happens

Trigger: Calling the bigtable get_logical_view tool where s.InstanceAdmin.LogicalViewInfo(ctx, instanceId, logicalViewId) errors: the logical view ID does not exist under the instance, instanceId is wrong, caller lacks bigtable views get permission (roles/bigtable.admin or viewer on views), or a transient gRPC failure occurs.

Common situations: Fetching a view that was deleted or renamed; confusing view IDs with view display names; service account without the relatively new logical-view IAM permissions; older client library versions lacking the LogicalViewInfo API against newer servers.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/e49212fe1b3d71b9. Report an issue: GitHub.