googleapis/mcp-toolbox · error
failed to list data scans: %w
Error message
failed to list data scans: %w
What it means
This error wraps an unknown (non-gRPC-status) failure returned while iterating Dataplex DataScan results in SearchDataQualityScans. The library first checks whether the error carries a gRPC status; if it does not (e.g. a client-side, context, or transport-level error), it falls back to %w wrapping so the underlying cause is preserved. It means the scan listing operation could not complete for a reason the Dataplex API did not report as a structured status.
Source
Thrown at internal/sources/dataplex/dataplex.go:416
Parent: fmt.Sprintf("projects/%s/locations/-", s.ProjectID()),
Filter: filter,
PageSize: int32(pageSize),
OrderBy: orderBy,
}
it := s.GetDataScanClient().ListDataScans(ctx, req)
var results []*dataplexpb.DataScan
for len(results) < pageSize {
scan, 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 scans: code=%s message=%s", st.Code(), st.Message())
}
return nil, fmt.Errorf("failed to list data scans: %w", err)
}
results = append(results, scan)
}
return results, nil
}
type DataProductSummary struct {
LocationID string `json:"locationId"`
DataProductID string `json:"dataProductId"`
DisplayName string `json:"displayName"`
OwnerEmails []string `json:"ownerEmails"`
AssetCount int32 `json:"assetCount"`
}
func (s *Source) ListDataProducts(
ctx context.Context,
filter string,
pageSize int,View on GitHub (pinned to 8cc6e09de2)
Solutions
- Inspect the wrapped cause with errors.Is/errors.Unwrap to identify the underlying transport, context, or auth error.
- Check that the context passed to SearchDataQualityScans is not cancelled or near its deadline before/during pagination.
- Verify network connectivity to the Dataplex endpoint (dataplex.googleapis.com:443) and retry the call.
- Regenerate/refresh Application Default Credentials and retry in case of transient auth refresh failure.
Example fix
// before
ctx := context.Background()
scans, err := src.SearchDataQualityScans(ctx, ...)
// after
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
scans, err := src.SearchDataQualityScans(ctx, ...)
if err != nil {
if errors.Is(err, context.DeadlineExceeded) { /* retry with larger timeout */ }
} Defensive patterns
Strategy: try-catch
Validate before calling
if err := ctx.Err(); err != nil { return nil, fmt.Errorf("context already done: %w", err) } Type guard
func asGRPCStatus(err error) (code string, msg string, ok bool) {
if st, ok := status.FromError(err); ok {
return st.Code().String(), st.Message(), true
}
return "", "", false
} Try / catch
scans, err := src.SearchDataQualityScans(ctx, query, pageSize)
if err != nil {
var ctxErr error
switch {
case errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded):
ctxErr = err // retry with fresh context
default:
return fmt.Errorf("scan search failed: %w", err)
}
_ = ctxErr
} Prevention
- Always pass a context with an adequate timeout for paginated list calls.
- Check ctx.Err() before starting long iterations.
- Retry transient network errors with exponential backoff.
- Keep credentials refreshed to avoid token-refresh failures mid-call.
When it happens
Trigger: Calling SearchDataQualityScans when iterator.Next() returns a non-gRPC error: a cancelled or deadline-exceeded context that surfaces as a plain context error, a network disconnect producing a wrapped transport error, or a client construction/serialization failure inside the paging loop.
Common situations: Short-lived HTTP clients losing connectivity mid-pagination; callers passing a context that is cancelled while iterating many pages; proxy or firewall dropping the long-lived gRPC/HTTP stream; go-auth library token refresh failures surfaced as plain errors.
Related errors
- failed to list data products: %w
- failed to list data assets: %w
- failed to create Dataplex client for project %q: %w
- failed to list tables: %w
- failed to create Dataplex client for project %q: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/84ae608c0abe0f32.
Report an issue: GitHub.