Existing variant id assigned to new variant

Topic summary

Issue: Adding a new product variant with a duplicate option value via Shopify Admin GraphQL (bulk) API appears to merge into an existing variant without error.

Repro steps:

  • Product initially has two variants: Colour A and Colour B.
  • A third variant is sent with Colour B (duplicate), unique SKU, and no variant ID.
  • Bulk update request includes two existing variant IDs and the new third variant.

Observed behavior:

  • Response returns only two variants (not three).
  • The existing Colour B variant’s SKU changed to the new SKU (1000025); the third variant was not created.
  • No error was returned by the API.

Details:

  • Request specified options: [“Colour”].
  • Third variant included inventoryManagement: SHOPIFY and inventoryPolicy: DENY.
  • Response shows two variants with updated SKU and inventoryItem IDs.

Open questions:

  • Is silent merging on duplicate options expected behavior?
  • Should apps ensure variant option values are unique before sending updates?
  • Why do duplicate options sometimes return an error but other times merge without errors?

Status: Unresolved; author seeks clarification on expected API behavior and consistency. No images or attachments; sample request/response JSON is central to the issue.

Summarized with AI on December 28. AI used: gpt-5.

I have run into a bit of strange behavior that happens while updating products through Shopify admin Graphql api.

The situation is:

  1. A product is created in Shopify with two variants first with color A and second with color B

  2. After the product was created, a third variant is added with the same color B that already exists on the second variant

  3. When updating that product (with duplicate options), I got a valid response, only 2 variants in the response, not 3, and the SKU on the second variant was updated with the data from the third variant. The third variant wasn’t created.

This is the sample request I sent using the bulk API:

{
  "input": {
    "options": [
      "Colour"
    ],
    "variants": [
      {
        "price": 10.35,
        "compareAtPrice": 12.95,
        "sku": "1000023",
        "id": "48988948955415",
        "options": [
          "A"
        ]
      },
      {
        "price": 10.35,
        "compareAtPrice": 12.95,
        "sku": "1000024",
        "id": "48988948988183",
        "options": [
          "B"
        ]
      },
      {
        "price": 10.35,
        "compareAtPrice": 12.95,
        "sku": "1000025",
        "inventoryManagement": "SHOPIFY",
        "inventoryPolicy": "DENY",
        "options": [
          "B"
        ]
      }
    ],
    "id": "9433084887319"
  }
}

This is the response I got. Note only two variants in the response and no error and the sku changed on the existing variant:

{
  "data": {
    "id": "9433084887319",
    "variants": [
      {
        "id": "48988948955415",
        "sku": "1000023",
        "inventoryItem": {
          "id": "51034378043671"
        }
      },
      {
        "id": "48988948988183",
        "sku": "1000025",
        "inventoryItem": {
          "id": "51034378076439"
        }
      }
    ]
  },
  "__lineNumber": 0,
  "error": null
}

Is this expected behavior? Should we make sure the options are unique before sending them? It is a bit strange to me that sometimes duplicated options are returned as an error but then sometimes variants are just merged.