productSet GraphQL generating null error

I am getting the following error using the productSet mutation:


{
  "data": {
    "productSet": {
      "product": null,
      "userErrors": [
        {
          "message": "Something went wrong, please try again.",
          "field": [
            "input"
          ]
        }
      ]
    }
  }

Here is my query:

mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
  productSet(synchronous: $synchronous, input: $productSet) {
    product {
      id
      idProduct: metafield(key: "kp_idproduct", namespace: "products") {
        value
      }
      variants(first: 20) {
        nodes {
          id
          sku
          idProduct: metafield(key: "kp_idproduct", namespace: "products") {
            value
          }
        }
      }
    }
    userErrors {
      message
      field
    }
  }
}

Here is the input:

{
  "synchronous": true,
  "productSet": {
    "title": "Women's Solid Boy Short Underwear in Jade",
    "handle": "womens-solid-boy-short-underwear-in-jade",
    "productType": "Women's Boy Short Underwear",
    "status": "DRAFT",
    "collections": [
      "gid://shopify/Collection/33720911495406",
      "gid://shopify/Collection/33720911692014",
      "gid://shopify/Collection/33720911560942",
      "gid://shopify/Collection/34323785973998",
      "gid://shopify/Collection/34324075938030",
      "gid://shopify/Collection/34665419112686",
      "gid://shopify/Collection/35386268614894",
      "gid://shopify/Collection/35401506750702"
    ],
    "tags": "syncdate:2024-10-24, kp_idproduct:423269, parent_sku:WSU98-8-W-YRS-J, YGroup_wsu98, current_color_code:J, current_color_name:Jade, style:women's boy short underwear, style_sku:WSU98-8, design:solid, fabric:Signature Blend, gender:Women, department:Women, delivery:Spring 2023 D1, collection:Spring 15 Year Anniversary Collection, delivery:Fall 2022 D1, collection:15 Year Anniversary Collection, delivery:Spring 2022 D2, collection:The Start of Spring, delivery:Spring 2021 D1, collection:Fish and Wildlife, swatch_group:WSU98-8-W-YRS-3695, collection:Solids, sort_priority:90,  , cheeky, color:green, ladies,  underwears, undies, women, womens",
    "templateSuffix": "",
    "descriptionHtml": "Give your skin a treat with a silky-smooth first layer made from our luxuriously soft bamboo fabric. Our women's boy shorts sit low across the hips with perfect coverage in back.<br /><br />FEATURES:<ul><li>A non-slip, silicone edge keeps our underwear in all the right places</li><li>Breathable, buttery-soft Bamboo fabric (95% Viscose from Bamboo, 5% Spandex)</li><li>Machine washable</li><li>Now rated UPF 50+!</li></ul><br/><h3>KICKEE Bamboo Signature Blend</h3>Soft and stretchy to the touch and loved for its lightweight, breathable and temperature-regulating qualities, our <em>Signature Blend</em> is what put us on the map. KICKEE's <em>Signature Blend</em> will keep you cool, dry, and fresh in all conditions and climates. Made of 95% viscose from bamboo (organically and sustainably grown) and 5% spandex for stretch.<div class=\"fabricFitCare\"><strong>Fit and Care Notes:</strong> Lightweight and luxuriously soft. No fuss care - machine wash and tumble dry low.</div><br/><br/><a href=\"https://www.oeko-tex.com/v/23.HCN.65682\" target=\"_blank\"><img src=\"https://cdn.shopify.com/s/files/1/0635/3423/5886/files/OEKOTEX.png?v=1698441196\" alt=\"QR Code\"/></a>",
    "productOptions": [
      {
        "name": "Size",
        "position": 1,
        "values": [
          {
            "name": "XS"
          },
          {
            "name": "S"
          },
          {
            "name": "M"
          },
          {
            "name": "L"
          },
          {
            "name": "XL"
          },
          {
            "name": "2XL"
          },
          {
            "name": "3XL"
          }
        ]
      }
    ],
    "variants": [
      {
        "barcode": "195041054591",
        "sku": "WSU98-8-W-YRS-J-XS",
        "price": 15.05,
        "compareAtPrice": 21.5,
        "taxable": true,
        "taxCode": "PC040100",
        "inventoryPolicy": "DENY",
        "optionValues": {
          "name": "XS",
          "optionName": "Size"
        },
        "inventoryQuantities": {
          "quantity": 0,
          "name": "available",
          "locationId": "gid://shopify/Location/68367614190"
        },
        "metafields": [
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "423269"
          },
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "424741"
          }
        ]
      },
      {
        "barcode": "195041054577",
        "sku": "WSU98-8-W-YRS-J-S",
        "price": 15.05,
        "compareAtPrice": 21.5,
        "taxable": true,
        "taxCode": "PC040100",
        "inventoryPolicy": "DENY",
        "optionValues": {
          "name": "S",
          "optionName": "Size"
        },
        "inventoryQuantities": {
          "quantity": 0,
          "name": "available",
          "locationId": "gid://shopify/Location/68367614190"
        },
        "metafields": [
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "423269"
          },
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "424742"
          }
        ]
      },
      {
        "barcode": "195041054560",
        "sku": "WSU98-8-W-YRS-J-M",
        "price": 15.05,
        "compareAtPrice": 21.5,
        "taxable": true,
        "taxCode": "PC040100",
        "inventoryPolicy": "DENY",
        "optionValues": {
          "name": "M",
          "optionName": "Size"
        },
        "inventoryQuantities": {
          "quantity": 0,
          "name": "available",
          "locationId": "gid://shopify/Location/68367614190"
        },
        "metafields": [
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "423269"
          },
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "424743"
          }
        ]
      },
      {
        "barcode": "195041054553",
        "sku": "WSU98-8-W-YRS-J-L",
        "price": 15.05,
        "compareAtPrice": 21.5,
        "taxable": true,
        "taxCode": "PC040100",
        "inventoryPolicy": "DENY",
        "optionValues": {
          "name": "L",
          "optionName": "Size"
        },
        "inventoryQuantities": {
          "quantity": 0,
          "name": "available",
          "locationId": "gid://shopify/Location/68367614190"
        },
        "metafields": [
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "423269"
          },
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "424744"
          }
        ]
      },
      {
        "barcode": "195041054584",
        "sku": "WSU98-8-W-YRS-J-XL",
        "price": 15.05,
        "compareAtPrice": 21.5,
        "taxable": true,
        "taxCode": "PC040100",
        "inventoryPolicy": "DENY",
        "optionValues": {
          "name": "XL",
          "optionName": "Size"
        },
        "inventoryQuantities": {
          "quantity": 0,
          "name": "available",
          "locationId": "gid://shopify/Location/68367614190"
        },
        "metafields": [
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "423269"
          },
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "424745"
          }
        ]
      },
      {
        "barcode": "195041054539",
        "sku": "WSU98-8-W-YRS-J-2XL",
        "price": 17.05,
        "compareAtPrice": 23.5,
        "taxable": true,
        "taxCode": "PC040100",
        "inventoryPolicy": "DENY",
        "optionValues": {
          "name": "2XL",
          "optionName": "Size"
        },
        "inventoryQuantities": {
          "quantity": 0,
          "name": "available",
          "locationId": "gid://shopify/Location/68367614190"
        },
        "metafields": [
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "423269"
          },
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "424746"
          }
        ]
      },
      {
        "barcode": "195041054546",
        "sku": "WSU98-8-W-YRS-J-3XL",
        "price": 17.05,
        "compareAtPrice": 23.5,
        "taxable": true,
        "taxCode": "PC040100",
        "inventoryPolicy": "DENY",
        "optionValues": {
          "name": "3XL",
          "optionName": "Size"
        },
        "inventoryQuantities": {
          "quantity": 0,
          "name": "available",
          "locationId": "gid://shopify/Location/68367614190"
        },
        "metafields": [
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "423269"
          },
          {
            "namespace": "products",
            "key": "kp_idparent",
            "type": "number_integer",
            "value": "424747"
          }
        ]
      }
    ],
    "metafields": [
      {
        "namespace": "products",
        "key": "kp_idparent",
        "type": "number_integer",
        "value": "0"
      },
      {
        "namespace": "products",
        "key": "kp_idproduct",
        "type": "number_integer",
        "value": "423269"
      },
      {
        "namespace": "products",
        "key": "kp_sizechart",
        "type": "single_line_text_field",
        "value": "kickee_chart"
      },
      {
        "namespace": "products",
        "key": "kp_size_range",
        "type": "single_line_text_field",
        "value": ""
      }
    ]
  }
}

There is absolutely nothing wrong with the input according to the GraphQLi app. The error is caused someplace with the variants but it’s not the number of variants. If I include only 1 variant, I get the same error.

What is going on?

Oh…I messed up the metafields…identical keys. Ok

Glad you figured this out Chris! Let us know if you have any other questions!

Thank you! I appreciate the response.