Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix alt image field validation in ProductBulkCreate (#18174)
Filip Owczarek8240e86c9abf
diff --git a/saleor/graphql/product/bulk_mutations/product_bulk_create.py b/saleor/graphql/product/bulk_mutations/product_bulk_create.pyindex 8681d98176..8d688a2c34 100644--- a/saleor/graphql/product/bulk_mutations/product_bulk_create.py+++ b/saleor/graphql/product/bulk_mutations/product_bulk_create.py@@ -459,7 +459,7 @@ class ProductBulkCreate(BaseMutation):if alt and len(alt) > ALT_CHAR_LIMIT:index_error_map[product_index].append(ProductBulkCreateError(- path=f"media.{index}",+ path=f"media.{index}.alt",message=f"Alt field exceeds the character "f"limit of {ALT_CHAR_LIMIT}.",code=ProductBulkCreateErrorCode.INVALID.value,diff --git a/saleor/graphql/product/tests/mutations/test_product_bulk_create.py b/saleor/graphql/product/tests/mutations/test_product_bulk_create.pyindex 739d3e3c9e..f851b96bdf 100644--- a/saleor/graphql/product/tests/mutations/test_product_bulk_create.py+++ b/saleor/graphql/product/tests/mutations/test_product_bulk_create.py@@ -2602,9 +2602,11 @@ def test_product_bulk_create_with_media_incorrect_alt(error_1 = data["results"][0]["errors"]assert error_1assert len(error_1) == 2- for error in error_1:+ for index, error in enumerate(error_1):assert error["code"] == ProductBulkCreateErrorCode.INVALID.name+ assert error["path"] == f"media.{index}.alt"error_2 = data["results"][1]["errors"]assert error_2[0]["code"] == ProductBulkCreateErrorCode.INVALID.name+ assert error_2[0]["path"] == "media.0.alt"assert len(error_2) == 1assert data["count"] == 0