Repository: saleor/saleor

Issue:
Bug: productBulkCreate issue with slug creation
### What are you trying to achieve?

Create products with `productBulkCreate` mutation, but their name consists only characters which can't be in slugs (for example "-").

Related PR #14378

### Steps to reproduce the problem

1. Send mutation:
```
mutation BulkCreate{
  productBulkCreate(errorPolicy: REJECT_FAILED_ROWS, products:[
    {name: "-", attributes: [], productType: "UHJvZHVjdFR5cGU6Njk4"},
  ]){
    results{
      product{
        id
        name
        slug
      }
    }errors{
      path
      message
      code
    }
  }
}
```
2. It returns: 
```
{
  "data": {
    "productBulkCreate": {
      "results": [
        {
          "product": null
        }
      ],
      "errors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 0,
      "maximumAvailable": 50000
    }
  }
}
```
No error message is returned with the response, which makes debugging complicated.

Whats weird, products _can_ be created, just need to be submitted _twice_:
1. Request:
```
mutation BulkCreate{
  productBulkCreate(errorPolicy: REJECT_FAILED_ROWS, products:[
    {name: "-", attributes: [], productType: "UHJvZHVjdFR5cGU6Njk4"},
    {name: "-", attributes: [], productType: "UHJvZHVjdFR5cGU6Njk4"},
  ]){
    results{
      product{
        id
        name
        slug
      }
    }errors{
      path
      message
      code
    }
  }
}
```

Response: 
```
{
  "data": {
    "productBulkCreate": {
      "results": [
        {
          "product": null  // the first one fails
        },
        {
          "product": {  // the same data passes for the second one
            "id": "UHJvZHVjdDo3ODY=",
            "name": "-",
            "slug": "-14"  // I've already created 13 products with this slug before, hence -14
          }
        }
      ],
      "errors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 0,
      "maximumAvailable": 50000
    }
  }
}
```

### What did you expect to happen?

Products to be created with a proper slug, every time.

### Logs

_No response_

### Environment

Saleor version: 3.14.30
OS and version: 



Discussion:

Resolving patch:
diff --git a/saleor/graphql/product/bulk_mutations/product_bulk_create.py b/saleor/graphql/product/bulk_mutations/product_bulk_create.py
--- a/saleor/graphql/product/bulk_mutations/product_bulk_create.py
+++ b/saleor/graphql/product/bulk_mutations/product_bulk_create.py
@@ -207,6 +207,12 @@ class Meta:
     def generate_unique_slug(cls, slugable_value, new_slugs):
         slug = slugify(unidecode(slugable_value))
 
+        # in case when slugable_value contains only not allowed in slug characters,
+        # slugify function will return empty string, so we need to provide some default
+        # value
+        if slug == "":
+            slug = "-"
+
         search_field = "slug__iregex"
         pattern = rf"{slug}-\d+$|{slug}$"
         lookup = {search_field: pattern}


Test patch:
diff --git a/saleor/graphql/product/tests/mutations/test_product_bulk_create.py b/saleor/graphql/product/tests/mutations/test_product_bulk_create.py
--- a/saleor/graphql/product/tests/mutations/test_product_bulk_create.py
+++ b/saleor/graphql/product/tests/mutations/test_product_bulk_create.py
@@ -149,6 +149,52 @@ def test_product_bulk_create_with_base_data(
     assert args == {product.id for product in products}
 
 
+def test_product_bulk_create_with_no_slug_and_name_with_unslugify_characters(
+    staff_api_client,
+    product_type,
+    category,
+    permission_manage_products,
+):
+    # given
+    product_type_id = graphene.Node.to_global_id("ProductType", product_type.pk)
+    category_id = graphene.Node.to_global_id("Category", category.pk)
+
+    product_name = "-->"
+
+    products = [
+        {
+            "productType": product_type_id,
+            "category": category_id,
+            "name": product_name,
+        },
+        {
+            "productType": product_type_id,
+            "category": category_id,
+            "name": product_name,
+        },
+    ]
+
+    # when
+    staff_api_client.user.user_permissions.add(permission_manage_products)
+    response = staff_api_client.post_graphql(
+        PRODUCT_BULK_CREATE_MUTATION,
+        {"products": products},
+    )
+    content = get_graphql_content(response)
+    data = content["data"]["productBulkCreate"]
+
+    # then
+    products = Product.objects.all()
+    assert not data["results"][0]["errors"]
+    assert not data["results"][1]["errors"]
+    assert data["count"] == 2
+    assert data["results"][0]["product"]["name"] == product_name
+    assert data["results"][0]["product"]["slug"] == "-"
+    assert data["results"][1]["product"]["name"] == product_name
+    assert data["results"][1]["product"]["slug"] == "--2"
+    assert len(products) == 2
+
+
 @patch("saleor.plugins.manager.PluginsManager.product_created")
 def test_product_bulk_create_send_product_created_webhook(
     created_webhook_mock,