{"record":{"id":"b767afba0d61ef7a","repo":"googleapis/mcp-toolbox","slug":"failed-to-list-data-assets-code-s-message-s","errorCode":null,"errorMessage":"failed to list data assets: code=%s message=%s","messagePattern":"failed to list data assets: code=(.+?) message=(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dataplex/dataplex.go","lineNumber":578,"sourceCode":"\tparent := fmt.Sprintf(\"projects/%s/locations/%s/dataProducts/%s\", s.ProjectID(), locationID, dataProductID)\n\treq := &dataplexpb.ListDataAssetsRequest{\n\t\tParent:   parent,\n\t\tFilter:   filter,\n\t\tPageSize: int32(pageSize),\n\t\tOrderBy:  orderBy,\n\t}\n\n\tit := s.GetDataProductClient().ListDataAssets(ctx, req)\n\tvar results []*DataAsset\n\n\tfor len(results) < pageSize {\n\t\tasset, err := it.Next()\n\t\tif err == iterator.Done {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\tif st, ok := grpcstatus.FromError(err); ok {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to list data assets: code=%s message=%s\", st.Code(), st.Message())\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"failed to list data assets: %w\", err)\n\t\t}\n\t\tparts := strings.Split(asset.GetName(), \"/\")\n\t\tvar locID, prodID, assetID string\n\t\tif len(parts) >= 8 && parts[0] == \"projects\" && parts[2] == \"locations\" && parts[4] == \"dataProducts\" && parts[6] == \"dataAssets\" {\n\t\t\tlocID = parts[3]\n\t\t\tprodID = parts[5]\n\t\t\tassetID = parts[7]\n\t\t}\n\t\tresults = append(results, &DataAsset{\n\t\t\tLocationID:    locID,\n\t\t\tDataProductID: prodID,\n\t\t\tDataAssetID:   assetID,\n\t\t\tResourceURI:   asset.GetResource(),\n\t\t\tLabels:        asset.GetLabels(),\n\t\t})\n\t}","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dataplex/dataplex.go#L560-L596","documentation":"While iterating DataAsset results in ListDataAssets, the call returned a gRPC error with a structured status; the library surfaces the status code and message in this error. It means the Dataplex API itself rejected the ListDataAssets request.","triggerScenarios":"The parent 'projects/{p}/locations/{l}/dataProducts/{id}' is wrong (bad location or data product ID), the caller lacks dataplex.dataAssets.list permission, or the filter/orderBy expression is invalid.","commonSituations":"Service account missing roles/dataplex.viewer or dataplex.dataReader; referencing a data product that was deleted; invalid filter field names; Dataplex API not enabled in the project.","solutions":["Read the embedded code= and message= fields to identify the exact gRPC status.","Grant the service account dataplex.dataAssets.list permission (roles/dataplex.viewer/dataReader).","Verify the location ID and data product ID in the parent resource name exist.","Check filter/orderBy syntax against the Dataplex ListDataAssets reference."],"exampleFix":"// before (deleted product)\nprodID := \"old-product\"\n// after (verify first)\nproducts, err := src.ListDataProducts(ctx, \"\", 50, \"\") // confirm prodID still listed","handlingStrategy":"try-catch","validationCode":"if locationID == \"\" || dataProductID == \"\" {\n\treturn errors.New(\"locationID and dataProductID are required\")\n}","typeGuard":"func isNotFound(err error) bool {\n\tst, ok := status.FromError(err)\n\treturn ok && st.Code() == codes.NotFound\n}","tryCatchPattern":"assets, err := src.ListDataAssets(ctx, locID, prodID, filter, pageSize, orderBy)\nif err != nil {\n\tif isNotFound(err) {\n\t\treturn fmt.Errorf(\"data product %q not found in %s: %w\", prodID, locID, err)\n\t}\n\tif isPermissionDenied(err) {\n\t\treturn fmt.Errorf(\"grant dataplex.dataReader IAM: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Verify the data product exists (via ListDataProducts) before listing its assets.","Grant dataplex.dataAssets.list permissions (roles/dataplex.viewer or dataReader).","Validate location and product IDs before building the parent name.","Confirm the Dataplex API is enabled in the project."],"tags":["gcp","dataplex","grpc","iam","permissions"],"backgroundTag":"grpc-permission-denied","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}