ProductSet Mutation Issue: Images are Deleted or Restored with Each Mutation Execution

I’m experiencing strange behavior when executing the ProductSet mutation with the request provided below multiple times. When I run the ProductSet mutation with the exact same ProductSetInput for the second time, the image is not updated with the same Filename as expected. Instead, the image is deleted, causing it to disappear from the Shopify product page. When I execute the ProductSet mutation again (third time), the image is reattached, but it displays incorrectly, as shown in the attached image. Is the behavior different from that of the fileCreate mutation?

Here are my questions:

  1. Why is the image being deleted?
  2. What is wrong with the Input in the request, and is there a way to improve it?
  3. If this is a bug, what is a temporary workaround?

Below is the actual mutation request and variables used:

(The URL in originalSource is public, so you can use it as is.)

mutation ShopifyProductSet($identifier: ProductSetIdentifiers, $product: ProductSetInput!) {
  productSet(identifier: $identifier input: $product, synchronous: true) {
    product {
      title
      media(first: 10) {
        nodes {
          id
          mediaContentType
          alt
          preview {
            image {
              id
            }
          }
        }
      }
    }
    userErrors {
      message
    }
  }
}

variable

{
  "identifier": {
    "customId": {
      "namespace": "custom",
      "key": "id",
      "value": "1234567"
    }
  },
  "product": {
    "title": "Nike Running Shoess",
    "files": [
        {
          "alt": "Image",
          "contentType": "IMAGE",
          "duplicateResolutionMode": "REPLACE",
          "filename": "nike_running_shoess.png",
          "originalSource": "https://storage.googleapis.com/tmp-dev-sq-file-storeage/image/e7b5e1dc-cb5e-4966-adf8-152b2fb132be.png"
        }
    ],
    "metafields": [
      {
        "namespace": "custom",
        "key": "id",
      	"value": "1234567"
      }
    ]
  }
}

The product image processed with ProductSet using the same Input 3 or 4 times

Hey,

Can you check the media errors, warning and status on the media item in the response. It could just be the files being processed in the background

If you don’t need to update the images then you could just exclude files from your next mutation.
I’d also consider whether using productSet or the individual mutations for updating a product e.g productUpdate or specific mutations for media might work better for you as they are simpler and more focussed. I did a bit of background on here Hi, I'm Jordan - Shopify: Unlocking the power of Shopify's new Product Model & APIs

1 Like

Thanks! @JordanFinners .

No media errors have occurred, and regarding the status, I’m executing the second ProductSet after it reaches the “ready” state. However, even though I haven’t modified the Input, the images still seem to be deleted.

I’m considering ProductUpdate for updates, but due to the constraints of external systems like ERP, ProductSet is preferable for updates as well.

Are there any ways to avoid this issue or improve things through ProductSet’s input specifications?

I’ve included a request example, so please give the ProductSet mutation a try.

Issue still persists. See the similar issue I logged here:
https://community.shopify.dev/t/productset-mutation-with-duplicateresolutionmode-replace-causes-images-to-disappear-every-other-time/14516/3

Can someone from Shopify take a look?

From your link @brill it looks like its working now?
@poccari could you give it a retest please :folded_hands:

Are you still seeing this issue @poccari ?

@JordanFinners
Yes, it still occurs. The following is the mutation.

mutation ShopifyProductSet($identifier: ProductSetIdentifiers, $product: ProductSetInput!) {
	productSet(identifier: $identifier input: $product, synchronous: true) {
		product {
      id
			title
      media(first:10) {
        nodes{
          id
          mediaContentType
          alt
          status
          preview {
            image {
              id
            }
          }
        }
      }
		}
		userErrors {
			message
		}
	}
}

variable

{
  "identifier": {
    "customId": {
      "namespace": "custom",
      "key": "id",
      "value": "custom-id-02"
    }
  },
  "product": {
    "title": "Adidus Running CustomID 02",
    "files": [
    {
    "alt": "Image",
    "contentType": "IMAGE",
    "duplicateResolutionMode": "REPLACE",
    "filename": "Adidus_Running_CustomID_01.jpg",
    "originalSource": "https://storage.googleapis.com/tmp-dev-sq-file-storeage/image/unnamed.jpg"
  }
  ],
    "metafields": [
      {
        "namespace": "custom",
        "key": "id",
      	"value": "custom-id-02"
      }
    ]
  }
}

Resolved!