googleapis/mcp-toolbox · error

failed to list data products: %w

Error message

failed to list data products: %w

What it means

This is the fallback branch of the same ListDataProducts failure path: the iterator returned an error that does not carry a gRPC status, so the library wraps it with %w to preserve the original cause. It indicates a client-side or transport-level problem rather than an API-reported status.

Source

Thrown at internal/sources/dataplex/dataplex.go:460

		Parent:   parent,
		Filter:   filter,
		PageSize: int32(pageSize),
		OrderBy:  orderBy,
	}

	it := s.GetDataProductClient().ListDataProducts(ctx, req)
	var results []*DataProductSummary

	for len(results) < pageSize {
		dp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			if st, ok := grpcstatus.FromError(err); ok {
				return nil, fmt.Errorf("failed to list data products: code=%s message=%s", st.Code(), st.Message())
			}
			return nil, fmt.Errorf("failed to list data products: %w", err)
		}
		parts := strings.Split(dp.GetName(), "/")
		var locID, prodID string
		if len(parts) >= 6 && parts[0] == "projects" && parts[2] == "locations" && parts[4] == "dataProducts" {
			locID = parts[3]
			prodID = parts[5]
		}
		results = append(results, &DataProductSummary{
			LocationID:    locID,
			DataProductID: prodID,
			DisplayName:   dp.GetDisplayName(),
			OwnerEmails:   dp.GetOwnerEmails(),
			AssetCount:    dp.GetAssetCount(),
		})
	}
	return results, nil
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Unwrap the error (errors.Is/As) to find the root cause.
  2. Ensure the context is alive with sufficient timeout for full pagination.
  3. Retry with backoff if the cause is transient network failure.
  4. Check proxy/firewall stability for long-running list operations.

Example fix

// before
ctx := r.Context() // handler context, may be cancelled early
// after
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
Defensive patterns

Strategy: retry

Validate before calling

if err := ctx.Err(); err != nil { return nil, fmt.Errorf("context not viable: %w", err) }

Try / catch

var products []*DataProductSummary
err := retry.Do(func() error {
	var e error
	products, e = src.ListDataProducts(ctx, filter, pageSize, orderBy)
	return e
}, retry.Attempts(3), retry.Delay(time.Second))

Prevention

When it happens

Trigger: Non-gRPC errors from iterator.Next() during ListDataProducts: context cancellation/deadline, connection resets, or unexpected client/serialization errors while paging through data products.

Common situations: Context cancelled by an HTTP request handler timeout mid-pagination; intermittent network failures; SDK internal errors surfaced without a grpc status.

Related errors


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