googleapis/mcp-toolbox · error

failed to update table: %w

Error message

failed to update table: %w

What it means

This error wraps failures from either UpdateTableDisableChangeStream or UpdateTableWithChangeStream in Source.UpdateTable. The library wraps the underlying error with fmt.Errorf("failed to update table: %w", err), preserving the original gRPC cause. It fires when toggling (disabling or enabling with a 24h retention) a table's change stream fails at the API level.

Source

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

}

func (s *Source) ListTables(ctx context.Context) (any, error) {
	tables, err := s.Admin.Tables(ctx)
	if err != nil {
		return nil, fmt.Errorf("failed to list tables: %w", err)
	}
	return tables, nil
}

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

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Verify the table ID exists and the installed cloud.google.com/go/bigtable version supports change stream admin APIs (upgrade the module if not).
  2. Confirm the instance/region supports change streams and that the retention duration is acceptable to the API.
  3. Grant roles/bigtable.admin (bigtable.tables.update) to the caller.
  4. Retry transient gRPC failures with backoff; check status.Code(err) to distinguish NotFound/PermissionDenied/FailedPrecondition.

Example fix

// before
err = s.Admin.UpdateTableWithChangeStream(ctx, tableId, 24*time.Hour)
// after: check feature support / version before calling
if changeStreamsUnsupported {
    return nil, fmt.Errorf("change streams not supported for this instance/table")
}
err = s.Admin.UpdateTableWithChangeStream(ctx, tableId, 24*time.Hour)
Defensive patterns

Strategy: validation

Validate before calling

// Go: verify support before toggling change streams
if !changeStreamSupported { // check module version + instance/region capability
    return fmt.Errorf("change streams not supported for this instance/table")
}
if disableChangeStream == false && retention <= 0 {
    return fmt.Errorf("retention duration must be positive")
}

Type guard

func isUnimplemented(err error) bool {
    return status.Code(err) == codes.Unimplemented
}

Try / catch

if err := src.UpdateTable(ctx, tableId, disableChangeStream); err != nil {
    if status.Code(err) == codes.Unimplemented {
        return fmt.Errorf("upgrade cloud.google.com/go/bigtable; change stream admin API unavailable")
    }
    if status.Code(err) == codes.FailedPrecondition {
        return fmt.Errorf("change streams unsupported or conflicting retention: %w", err)
    }
    return fmt.Errorf("update table: %w", err)
}

Prevention

When it happens

Trigger: Calling the bigtable update_table tool where s.Admin.UpdateTableDisableChangeStream(ctx, tableId) or s.Admin.UpdateTableWithChangeStream(ctx, tableId, 24*time.Hour) errors: table not found, change streams not supported on the table/instance type, invalid retention period, missing bigtable.tables.update permission, or transient gRPC failure.

Common situations: Toggling change streams on a table in an instance/region that does not support them or where the feature flag is unavailable in the installed client library version; wrong table ID; service account lacking update permission; retention conflicts with an existing stream.

Related errors


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