googleapis/mcp-toolbox · error

failed to get table: %w

Error message

failed to get table: %w

What it means

This error wraps failures from the Bigtable Admin client's TableInfo call in Source.GetTable. The library wraps the underlying error with fmt.Errorf("failed to get table: %w", err); the real cause (table not found, permission denied, network) is preserved in the error chain. Resolve the wrapped gRPC status to diagnose.

Source

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

	err := s.InstanceAdmin.UpdateCluster(ctx, instanceId, clusterId, serveNodes)
	if err != nil {
		return nil, fmt.Errorf("failed to update cluster: %w", err)
	}
	return map[string]string{"status": "cluster updated successfully"}, nil
}

func (s *Source) DeleteCluster(ctx context.Context, instanceId, clusterId string) (any, error) {
	err := s.InstanceAdmin.DeleteCluster(ctx, instanceId, clusterId)
	if err != nil {
		return nil, fmt.Errorf("failed to delete cluster: %w", err)
	}
	return map[string]string{"status": "cluster deleted successfully"}, nil
}

func (s *Source) GetTable(ctx context.Context, tableId string) (any, error) {
	table, err := s.Admin.TableInfo(ctx, tableId)
	if err != nil {
		return nil, fmt.Errorf("failed to get table: %w", err)
	}
	return table, nil
}

func (s *Source) CreateTable(ctx context.Context, tableId, columnFamily string) (any, error) {
	err := s.Admin.CreateTable(ctx, tableId)
	if err != nil {
		return nil, fmt.Errorf("failed to create table: %w", err)
	}
	if columnFamily != "" {
		if err := s.Admin.CreateColumnFamily(ctx, tableId, columnFamily); err != nil {
			return nil, fmt.Errorf("failed to create column family: %w", err)
		}
	}
	return map[string]string{"status": "table created successfully"}, nil
}

func (s *Source) DeleteTable(ctx context.Context, tableId string) (any, error) {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Verify tableId is the bare table ID (e.g. "my-table", not "projects/p/instances/i/tables/my-table") and exists via list_tables.
  2. Check IAM roles (roles/bigtable.viewer or admin) for the service account.
  3. If using the emulator, confirm BIGTABLE_EMULATOR_HOST is set and the emulator is running.
  4. Retry transient gRPC failures with backoff; inspect status.Code(err) for NotFound vs PermissionDenied.

Example fix

// before: raw tableId from user input may include a full path
err := s.Admin.TableInfo(ctx, tableId)
// after: normalize input to a bare table ID first
tableId = path.Base(tableId)
err := s.Admin.TableInfo(ctx, tableId)
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: normalize and validate table ID before lookup
tableId = path.Base(strings.TrimSpace(tableId))
if !regexp.MustCompile(`^[_a-zA-Z0-9][-_.a-zA-Z0-9]*$`).MatchString(tableId) {
    return fmt.Errorf("invalid table id: %q", tableId)
}

Type guard

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

Try / catch

table, err := src.GetTable(ctx, tableId)
if err != nil {
    if status.Code(err) == codes.NotFound {
        return fmt.Errorf("table %q does not exist", tableId)
    }
    return fmt.Errorf("get table: %w", err)
}

Prevention

When it happens

Trigger: Calling the bigtable get_table tool where s.Admin.TableInfo(ctx, tableId) returns an error: tableId does not exist in the instance, caller lacks bigtable.tables.get, or the gRPC metadata/table administer client fails (timeout, endpoint unreachable).

Common situations: Querying a table by name instead of its plain ID (IDs exclude the project/instance prefix); table deleted by another process; service account without Bigtable Viewer/Admin; transient network errors or emulator misconfiguration (BIGTABLE_EMULATOR_HOST).

Related errors


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