Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add path field to ProductVariantBulkError (#12534)
SzymJ05df3bec57e2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 288ff377dc..95745ddb48 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,8 +5,10 @@ All notable, unreleased changes to this project will be documented in this file.3.14.0 [Unreleased]### Breaking changes+- `path` field for errors related with product variants input in `ProductBulkCreate` will return more detailed paths: `variants.1.stocks.0.warehouse` instead of `variants.1.warehouses` - #12534 by @SzymJ### GraphQL API+- Add `path` field to `ProductVariantBulkError` - #12534 by @SzymJ### Saleor Appsdiff --git a/saleor/graphql/core/types/common.py b/saleor/graphql/core/types/common.pyindex b19e3b5264..2135812895 100644--- a/saleor/graphql/core/types/common.py+++ b/saleor/graphql/core/types/common.py@@ -25,7 +25,12 @@ from ...core.doc_category import (DOC_CATEGORY_USERS,DOC_CATEGORY_WEBHOOKS,)-from ..descriptions import ADDED_IN_36, ADDED_IN_312, DEPRECATED_IN_3X_FIELD+from ..descriptions import (+ ADDED_IN_36,+ ADDED_IN_312,+ ADDED_IN_314,+ DEPRECATED_IN_3X_FIELD,+)from ..enums import (AccountErrorCode,AppErrorCode,@@ -456,6 +461,13 @@ class ProductBulkCreateError(BulkError):class ProductVariantBulkError(Error):code = ProductVariantBulkErrorCode(description="The error code.", required=True)+ path = graphene.String(+ description=(+ "Path to field that caused the error. A value of `null` indicates that "+ "the error isn't associated with a particular field." + ADDED_IN_314+ ),+ required=False,+ )attributes = NonNullList(graphene.ID,description="List of attributes IDs which causes the error.",diff --git a/saleor/graphql/product/bulk_mutations/product_bulk_create.py b/saleor/graphql/product/bulk_mutations/product_bulk_create.pyindex c42cc658a8..b0cb6c8f0d 100644--- a/saleor/graphql/product/bulk_mutations/product_bulk_create.py+++ b/saleor/graphql/product/bulk_mutations/product_bulk_create.py@@ -488,8 +488,8 @@ class ProductBulkCreate(BaseMutation):for error in errors:index_error_map[product_index].append(ProductBulkCreateError(- path=f"variants.{index}.{error.field}"- if error.field+ path=f"variants.{index}.{error.path}"+ if error.pathelse f"variants.{index}",message=error.message,code=error.code,diff --git a/saleor/graphql/product/bulk_mutations/product_variant_bulk_create.py b/saleor/graphql/product/bulk_mutations/product_variant_bulk_create.pyindex 3ca1bda874..10feb12cd4 100644--- a/saleor/graphql/product/bulk_mutations/product_variant_bulk_create.py+++ b/saleor/graphql/product/bulk_mutations/product_variant_bulk_create.py@@ -64,8 +64,10 @@ def clean_price(currency,channel_id,variant_index,+ listing_index,errors,index_error_map,+ path_prefix,):try:validate_price_precision(price, currency, CURRENCY_FRACTIONS)@@ -73,6 +75,7 @@ def clean_price(index_error_map[variant_index].append(ProductVariantBulkError(field=to_camel_case(field_name),+ path=f"{path_prefix}.{listing_index}.{to_camel_case(field_name)}",message=error.message,code=ProductVariantBulkErrorCode.INVALID_PRICE.value,channels=[channel_id],@@ -287,6 +290,7 @@ class ProductVariantBulkCreate(BaseMutation):index_error_map[variant_index].append(ProductVariantBulkError(field="attributes",+ path="attributes",message=message,code=code,attributes=invalid_attributes,@@ -322,6 +326,7 @@ class ProductVariantBulkCreate(BaseMutation):index_error_map[variant_index].append(ProductVariantBulkError(field="attributes",+ path="attributes",message=error.message,code=error.code,attributes=attributes,@@ -336,6 +341,7 @@ class ProductVariantBulkCreate(BaseMutation):index_error_map[variant_index].append(ProductVariantBulkError(field="attributes",+ path="attributes",message=message,code=ProductVariantBulkErrorCode.INVALID.value,attributes=invalid_attributes,@@ -363,8 +369,10 @@ class ProductVariantBulkCreate(BaseMutation):currency_code,channel_id,variant_index,+ listing_index,errors,index_error_map,+ path_prefix,):clean_price(price,@@ -372,8 +380,10 @@ class ProductVariantBulkCreate(BaseMutation):currency_code,channel_id,variant_index,+ listing_index,errors,index_error_map,+ path_prefix,)clean_price(cost_price,@@ -381,8 +391,10 @@ class ProductVariantBulkCreate(BaseMutation):currency_code,channel_id,variant_index,+ listing_index,errors,index_error_map,+ path_prefix,)@classmethod@@ -393,6 +405,7 @@ class ProductVariantBulkCreate(BaseMutation):errors,variant_index,index_error_map,+ path_prefix="channelListings",):channel_ids = [channel_listing["channel_id"] for channel_listing in channel_listings@@ -401,18 +414,9 @@ class ProductVariantBulkCreate(BaseMutation):duplicates = get_duplicated_values(channel_ids)if duplicates:- message = "Duplicated channel ID."- index_error_map[variant_index].append(- ProductVariantBulkError(- field="channelListings",- message=message,- code=ProductVariantBulkErrorCode.DUPLICATED_INPUT_ITEM.value,- channels=duplicates,- )- )if errors is not None:errors["channel_listings"] = ValidationError(- message=message,+ message="Duplicated channel ID.",code=ProductVariantBulkErrorCode.DUPLICATED_INPUT_ITEM.value,params={"channels": duplicates, "index": variant_index},)@@ -424,20 +428,11 @@ class ProductVariantBulkCreate(BaseMutation):]if channels_not_assigned_to_product:- message = "Product not available in channels."code = ProductVariantBulkErrorCode.PRODUCT_NOT_ASSIGNED_TO_CHANNEL.value- index_error_map[variant_index].append(- ProductVariantBulkError(- field="channelId",- message=message,- code=code,- channels=channels_not_assigned_to_product,- )- )if errors is not None:errors["channel_id"].append(ValidationError(- message=message,+ message="Product not available in channels.",code=code,params={"index": variant_index,@@ -446,13 +441,33 @@ class ProductVariantBulkCreate(BaseMutation):))- for channel_listing in channel_listings:+ for listing_index, channel_listing in enumerate(channel_listings):channel_id = channel_listing["channel_id"]+ errors_count_before_prices = len(index_error_map[variant_index])- if (- channel_id in channels_not_assigned_to_product- or channel_id in duplicates- ):+ if channel_id in channels_not_assigned_to_product:+ code = ProductVariantBulkErrorCode.PRODUCT_NOT_ASSIGNED_TO_CHANNEL.value+ index_error_map[variant_index].append(+ ProductVariantBulkError(+ field="channelId",+ path=f"{path_prefix}.{listing_index}.channelId",+ message="Product not available in channels.",+ code=code,+ channels=[channel_id],+ )+ )+ continue++ if channel_id in duplicates:+ index_error_map[variant_index].append(+ ProductVariantBulkError(+ field="channelId",+ path=f"{path_prefix}.{listing_index}.channelId",+ message="Duplicated channel ID.",+ code=ProductVariantBulkErrorCode.DUPLICATED_INPUT_ITEM.value,+ channels=[channel_id],+ )+ )continuechannel_listing["channel"] = product_channel_global_id_to_instance_map[@@ -462,16 +477,16 @@ class ProductVariantBulkCreate(BaseMutation):cost_price = channel_listing.get("cost_price")currency_code = channel_listing["channel"].currency_code- errors_count_before_prices = len(index_error_map[variant_index])-cls.clean_prices(price,cost_price,currency_code,channel_id,variant_index,+ listing_index,errors,index_error_map,+ path_prefix,)if len(index_error_map[variant_index]) > errors_count_before_prices:@@ -489,6 +504,7 @@ class ProductVariantBulkCreate(BaseMutation):errors,variant_index,index_error_map,+ path_prefix="stocks",):stocks_to_create = []warehouse_ids = [stock["warehouse"] for stock in stocks_data]@@ -500,51 +516,51 @@ class ProductVariantBulkCreate(BaseMutation):}if wrong_warehouse_ids:- message = "Not existing warehouse ID."- index_error_map[variant_index].append(- ProductVariantBulkError(- field="warehouses",- message=message,- code=ProductVariantBulkErrorCode.NOT_FOUND.value,- warehouses=wrong_warehouse_ids,- )- )if errors is not None:errors["warehouses"] = ValidationError(- message,+ "Not existing warehouse ID.",code=ProductVariantBulkErrorCode.NOT_FOUND.value,params={"warehouses": wrong_warehouse_ids, "index": variant_index},)duplicates = get_duplicated_values(warehouse_ids)if duplicates:- message = "Duplicated warehouse ID."- index_error_map[variant_index].append(- ProductVariantBulkError(- field="stocks",- message=message,- code=ProductVariantBulkErrorCode.DUPLICATED_INPUT_ITEM.value,- warehouses=duplicates,- )- )if errors is not None:errors["stocks"] = ValidationError(- message,+ "Duplicated warehouse ID.",code=ProductVariantBulkErrorCode.DUPLICATED_INPUT_ITEM.value,params={"warehouses": duplicates, "index": variant_index},)- for stock_data in stocks_data:- if (- stock_data["warehouse"] in duplicates- or stock_data["warehouse"] in wrong_warehouse_ids- ):+ for stock_index, stock_data in enumerate(stocks_data):+ if stock_data["warehouse"] in wrong_warehouse_ids:+ index_error_map[variant_index].append(+ ProductVariantBulkError(+ field="warehouses",+ path=f"{path_prefix}.{stock_index}.warehouse",+ message="Not existing warehouse ID.",+ code=ProductVariantBulkErrorCode.NOT_FOUND.value,+ warehouses=[stock_data["warehouse"]],+ )+ )continue- else:- stock_data["warehouse"] = warehouse_global_id_to_instance_map[- stock_data["warehouse"]- ]- stocks_to_create.append(stock_data)++ if stock_data["warehouse"] in duplicates:+ index_error_map[variant_index].append(+ ProductVariantBulkError(+ field="warehouse",+ path=f"{path_prefix}.{stock_index}.warehouse",+ message="Duplicated warehouse ID.",+ code=ProductVariantBulkErrorCode.DUPLICATED_INPUT_ITEM.value,+ warehouses=[stock_data["warehouse"]],+ )+ )+ continue++ stock_data["warehouse"] = warehouse_global_id_to_instance_map[+ stock_data["warehouse"]+ ]+ stocks_to_create.append(stock_data)return stocks_to_create@@ -560,6 +576,7 @@ class ProductVariantBulkCreate(BaseMutation):index_error_map[index].append(ProductVariantBulkError(field=to_camel_case(key),+ path=to_camel_case(key),message=e.messages[0],code=e.code,)@@ -614,6 +631,7 @@ class ProductVariantBulkCreate(BaseMutation):index_error_map[index].append(ProductVariantBulkError(field="weight",+ path="weight",message=message,code=code,)@@ -634,6 +652,7 @@ class ProductVariantBulkCreate(BaseMutation):index_error_map[index].append(ProductVariantBulkError(field="quantity_limit_per_customer",+ path="quantity_limit_per_customer",message=message,code=code,)@@ -649,7 +668,9 @@ class ProductVariantBulkCreate(BaseMutation):message = "Duplicated SKU."code = ProductVariantBulkErrorCode.UNIQUE.valueindex_error_map[index].append(- ProductVariantBulkError(field="sku", message=message, code=code)+ ProductVariantBulkError(+ field="sku", path="sku", message=message, code=code+ ))if errors is not None:errors["sku"].append(diff --git a/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py b/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.pyindex 48905a10f9..40fb963ff0 100644--- a/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py+++ b/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py@@ -176,7 +176,9 @@ class ProductVariantBulkUpdate(BaseMutation):currency_code,channel_id,variant_index,+ listing_index,index_error_map,+ path_prefix="channelListings.update",):clean_price(price,@@ -184,8 +186,10 @@ class ProductVariantBulkUpdate(BaseMutation):currency_code,channel_id,variant_index,+ listing_index,None,index_error_map,+ path_prefix,)clean_price(cost_price,@@ -193,8 +197,10 @@ class ProductVariantBulkUpdate(BaseMutation):currency_code,channel_id,variant_index,+ listing_index,None,index_error_map,+ path_prefix,)@classmethod@@ -206,8 +212,6 @@ class ProductVariantBulkUpdate(BaseMutation):variant_index,index_error_map,):- wrong_listings_ids: list = []-if listings_data := cleaned_input["channel_listings"].get("create"):cleaned_input["channel_listings"]["create"@@ -217,14 +221,22 @@ class ProductVariantBulkUpdate(BaseMutation):None,variant_index,index_error_map,+ "channelListings.create",)if listings_data := cleaned_input["channel_listings"].get("update"):listings_to_update = []- for listing_data in listings_data:+ for index, listing_data in enumerate(listings_data):listing_id = listing_data["channel_listing"]-if listing_id not in listings_global_id_to_instance_map.keys():- wrong_listings_ids.append(listing_id)+ index_error_map[variant_index].append(+ ProductVariantBulkError(+ field="channelListing",+ path=f"channelListings.update.{index}.channelListing",+ message="Channel listing was not found.",+ code=ProductVariantBulkErrorCode.NOT_FOUND.value,+ channel_listings=[listing_id],+ )+ )continuechannel_listing = listings_global_id_to_instance_map[listing_id]@@ -240,6 +252,7 @@ class ProductVariantBulkUpdate(BaseMutation):currency_code,channel_id,variant_index,+ index,index_error_map,)@@ -252,24 +265,21 @@ class ProductVariantBulkUpdate(BaseMutation):if listings_ids := cleaned_input["channel_listings"].get("remove"):listings_to_remove = []- for listing_id in listings_ids:+ for index, listing_id in enumerate(listings_ids):if listing_id not in listings_global_id_to_instance_map.keys():- wrong_listings_ids.append(listing_id)+ index_error_map[variant_index].append(+ ProductVariantBulkError(+ path=f"channelListings.remove.{index}",+ message="Channel listing was not found.",+ code=ProductVariantBulkErrorCode.NOT_FOUND.value,+ channel_listings=[listing_id],+ )+ )continuelistings_to_remove.append(graphene.Node.from_global_id(listing_id)[1])cleaned_input["channel_listings"]["remove"] = listings_to_remove- if wrong_listings_ids:- index_error_map[variant_index].append(- ProductVariantBulkError(- field="channelListing",- message="Channel listing was not found.",- code=ProductVariantBulkErrorCode.NOT_FOUND.value,- channel_listings=[wrong_listings_ids],- )- )-@classmethoddef clean_stocks(cls,@@ -279,8 +289,6 @@ class ProductVariantBulkUpdate(BaseMutation):variant_index,index_error_map,):- wrong_stocks_ids: list = []-if stocks_data := cleaned_input["stocks"].get("create"):cleaned_input["stocks"]["create"] = ProductVariantBulkCreate.clean_stocks(stocks_data,@@ -288,14 +296,23 @@ class ProductVariantBulkUpdate(BaseMutation):None,variant_index,index_error_map,+ "stocks.create",)if stocks_data := cleaned_input["stocks"].get("update"):stocks_to_update = []- for stock_data in stocks_data:+ for stock_index, stock_data in enumerate(stocks_data):stock_id = stock_data["stock"]if stock_id not in stock_global_id_to_instance_map.keys():- wrong_stocks_ids.append(stock_id)+ index_error_map[variant_index].append(+ ProductVariantBulkError(+ field="stock",+ path=f"stocks.update.{stock_index}.stock",+ message="Stock was not found.",+ code=ProductVariantBulkErrorCode.NOT_FOUND.value,+ stocks=[stock_id],+ )+ )continuestock_data["stock"] = stock_global_id_to_instance_map[stock_id]@@ -306,23 +323,21 @@ class ProductVariantBulkUpdate(BaseMutation):if stocks_ids := cleaned_input["stocks"].get("remove"):stocks_to_remove = []- for stock_id in stocks_ids:+ for stock_index, stock_id in enumerate(stocks_ids):if stock_id not in stock_global_id_to_instance_map.keys():- wrong_stocks_ids.append(stock_id)+ index_error_map[variant_index].append(+ ProductVariantBulkError(+ field="stock",+ path=f"stocks.remove.{stock_index}",+ message="Stock was not found.",+ code=ProductVariantBulkErrorCode.NOT_FOUND.value,+ stocks=[stock_id],+ )+ )continuestocks_to_remove.append(graphene.Node.from_global_id(stock_id)[1])cleaned_input["stocks"]["remove"] = stocks_to_remove- if wrong_stocks_ids:- index_error_map[variant_index].append(- ProductVariantBulkError(- field="stock",- message="Stock was not found.",- code=ProductVariantBulkErrorCode.NOT_FOUND.value,- stocks=[wrong_stocks_ids],- )- )-@classmethoddef clean_variant(cls,@@ -452,7 +467,10 @@ class ProductVariantBulkUpdate(BaseMutation):message = f"Variant #{variant_id} does not exist."index_error_map[index].append(ProductVariantBulkError(- field="id", message=message, code=ProductErrorCode.INVALID+ field="id",+ pth="id",+ message=message,+ code=ProductErrorCode.INVALID,))continuediff --git a/saleor/graphql/product/tests/mutations/test_product_bulk_create.py b/saleor/graphql/product/tests/mutations/test_product_bulk_create.pyindex 2fe0d4635e..d02b2ea3eb 100644--- a/saleor/graphql/product/tests/mutations/test_product_bulk_create.py+++ b/saleor/graphql/product/tests/mutations/test_product_bulk_create.py@@ -1275,7 +1275,7 @@ def test_product_bulk_create_with_variants_and_invalid_stock(assert not data["results"][0]["product"]errors = data["results"][0]["errors"]assert errors- assert errors[0]["path"] == "variants.1.warehouses"+ assert errors[0]["path"] == "variants.1.stocks.0.warehouse"assert errors[0]["code"] == ProductBulkCreateErrorCode.NOT_FOUND.nameassert data["count"] == 0@@ -1500,9 +1500,9 @@ def test_product_bulk_create_with_variants_and_channel_listings_with_wrong_priceassert not data["results"][0]["product"]errors = data["results"][0]["errors"]assert len(errors) == 2- assert errors[0]["path"] == "variants.0.price"+ assert errors[0]["path"] == "variants.0.channelListings.0.price"assert errors[0]["code"] == ProductBulkCreateErrorCode.INVALID_PRICE.nameassert errors[0]["channels"] == [channel_id]- assert errors[1]["path"] == "variants.0.costPrice"+ assert errors[1]["path"] == "variants.0.channelListings.0.costPrice"assert errors[1]["code"] == ProductBulkCreateErrorCode.INVALID_PRICE.nameassert errors[1]["channels"] == [channel_id]diff --git a/saleor/graphql/product/tests/mutations/test_product_variant_bulk_create.py b/saleor/graphql/product/tests/mutations/test_product_variant_bulk_create.pyindex 7232335f2e..673ac7cd1d 100644--- a/saleor/graphql/product/tests/mutations/test_product_variant_bulk_create.py+++ b/saleor/graphql/product/tests/mutations/test_product_variant_bulk_create.py@@ -78,6 +78,7 @@ PRODUCT_VARIANT_BULK_CREATE_MUTATION = """}errors {field+ pathmessagecodewarehouses@@ -986,9 +987,10 @@ def test_product_variant_bulk_create_duplicated_warehouses(assert not data["results"][0]["errors"]assert not data["results"][0]["productVariant"]assert not data["results"][1]["productVariant"]- assert len(errors) == 1+ assert len(errors) == 2error = errors[0]- assert error["field"] == "stocks"+ assert error["field"] == "warehouse"+ assert error["path"] == "stocks.0.warehouse"assert error["code"] == ProductVariantBulkErrorCode.DUPLICATED_INPUT_ITEM.nameassert error["warehouses"] == [warehouse1_id]@@ -1044,9 +1046,10 @@ def test_product_variant_bulk_create_duplicated_warehouses_when_ignore_failed(assert data["results"][0]["productVariant"]assert data["results"][1]["productVariant"]assert not data["results"][1]["productVariant"]["stocks"]- assert len(errors) == 1+ assert len(errors) == 2error = errors[0]- assert error["field"] == "stocks"+ assert error["field"] == "warehouse"+ assert error["path"] == "stocks.0.warehouse"assert error["code"] == ProductVariantBulkErrorCode.DUPLICATED_INPUT_ITEM.nameassert error["warehouses"] == [warehouse1_id]@@ -1342,9 +1345,9 @@ def test_product_variant_bulk_create_duplicated_channels(data = content["data"]["productVariantBulkCreate"]# then- assert len(data["results"][0]["errors"]) == 1+ assert len(data["results"][0]["errors"]) == 2error = data["results"][0]["errors"][0]- assert error["field"] == "channelListings"+ assert error["path"] == "channelListings.0.channelId"assert error["code"] == ProductVariantBulkErrorCode.DUPLICATED_INPUT_ITEM.nameassert error["channels"] == [channel_id]assert product_variant_count == ProductVariant.objects.count()@@ -1391,11 +1394,12 @@ def test_product_variant_bulk_create_duplicated_channels_when_ignore_failed(data = content["data"]["productVariantBulkCreate"]# then- assert len(data["results"][0]["errors"]) == 1+ assert len(data["results"][0]["errors"]) == 2assert data["results"][0]["productVariant"]assert not data["results"][0]["productVariant"]["channelListings"]error = data["results"][0]["errors"][0]- assert error["field"] == "channelListings"+ assert error["field"] == "channelId"+ assert error["path"] == "channelListings.0.channelId"assert error["code"] == ProductVariantBulkErrorCode.DUPLICATED_INPUT_ITEM.nameassert error["channels"] == [channel_id]assert product_variant_count + 1 == ProductVariant.objects.count()@@ -1442,15 +1446,19 @@ def test_product_variant_bulk_create_too_many_decimal_places_in_price(errors = data["results"][0]["errors"]assert len(errors) == 4assert errors[0]["field"] == "price"+ assert errors[0]["path"] == "channelListings.0.price"assert errors[0]["code"] == ProductVariantBulkErrorCode.INVALID_PRICE.nameassert errors[0]["channels"] == [channel_id]assert errors[1]["field"] == "costPrice"+ assert errors[1]["path"] == "channelListings.0.costPrice"assert errors[1]["code"] == ProductVariantBulkErrorCode.INVALID_PRICE.nameassert errors[1]["channels"] == [channel_id]assert errors[2]["field"] == "price"+ assert errors[2]["path"] == "channelListings.1.price"assert errors[2]["code"] == ProductVariantBulkErrorCode.INVALID_PRICE.nameassert errors[2]["channels"] == [channel_pln_id]assert errors[3]["field"] == "costPrice"+ assert errors[3]["path"] == "channelListings.1.costPrice"assert errors[3]["code"] == ProductVariantBulkErrorCode.INVALID_PRICE.nameassert errors[3]["channels"] == [channel_pln_id]assert product_variant_count == ProductVariant.objects.count()@@ -1829,6 +1837,7 @@ def test_product_variant_bulk_create_many_errors(input_4_errors = data["results"][3]["errors"]assert input_3_errors[0] == {"field": "sku",+ "path": "sku","code": ProductVariantBulkErrorCode.UNIQUE.name,"message": ANY,"warehouses": None,@@ -1836,6 +1845,7 @@ def test_product_variant_bulk_create_many_errors(}assert input_4_errors[0] == {"field": "attributes",+ "path": "attributes","code": ProductVariantBulkErrorCode.ATTRIBUTE_CANNOT_BE_ASSIGNED.name,"message": ANY,"warehouses": None,@@ -1900,6 +1910,7 @@ def test_product_variant_bulk_create_many_errors_with_ignore_failed(input_4_errors = data["results"][3]["errors"]assert input_3_errors[0] == {"field": "sku",+ "path": "sku","code": ProductVariantBulkErrorCode.UNIQUE.name,"message": ANY,"warehouses": None,@@ -1907,6 +1918,7 @@ def test_product_variant_bulk_create_many_errors_with_ignore_failed(}assert input_4_errors[0] == {"field": "attributes",+ "path": "attributes","code": ProductVariantBulkErrorCode.ATTRIBUTE_CANNOT_BE_ASSIGNED.name,"message": ANY,"warehouses": None,@@ -1971,6 +1983,7 @@ def test_product_variant_bulk_create_many_errors_with_reject_failed_rows(input_4_errors = data["results"][3]["errors"]assert input_3_errors[0] == {"field": "sku",+ "path": "sku","code": ProductVariantBulkErrorCode.UNIQUE.name,"message": ANY,"warehouses": None,@@ -1979,6 +1992,7 @@ def test_product_variant_bulk_create_many_errors_with_reject_failed_rows(assert input_4_errors[0] == {"field": "attributes",+ "path": "attributes","code": ProductVariantBulkErrorCode.ATTRIBUTE_CANNOT_BE_ASSIGNED.name,"message": ANY,"warehouses": None,diff --git a/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py b/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.pyindex f5fdc6f2ce..ce7b84598d 100644--- a/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py+++ b/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py@@ -19,6 +19,7 @@ PRODUCT_VARIANT_BULK_UPDATE_MUTATION = """results{errors {field+ pathmessagecodewarehouses@@ -300,6 +301,7 @@ def test_product_variant_bulk_update_stocks_with_invalid_warehouse(assert data["count"] == 0error = data["results"][0]["errors"][0]assert error["field"] == "warehouses"+ assert error["path"] == "stocks.create.0.warehouse"assert error["code"] == ProductVariantBulkErrorCode.NOT_FOUND.nameassert error["warehouses"] == [not_existing_warehouse_id]@@ -472,6 +474,7 @@ def test_product_variant_bulk_update_channel_listings_with_invalid_price(assert not data["results"][0]["productVariant"]error = data["results"][0]["errors"][0]assert error["field"] == "price"+ assert error["path"] == "channelListings.update.0.price"assert error["code"] == ProductVariantBulkErrorCode.INVALID_PRICE.namediff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex eba3c368ca..dd41ee1c5f 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -20029,6 +20029,13 @@ type ProductVariantBulkError @doc(category: "Products") {"""The error code."""code: ProductVariantBulkErrorCode!+ """+ Path to field that caused the error. A value of `null` indicates that the error isn't associated with a particular field.++ Added in Saleor 3.14.+ """+ path: String+"""List of attributes IDs which causes the error."""attributes: [ID!]