Errors when updating product options ("base could not be saved successfully" & "name of Option is not unique")

Highlighted
Shopify Partner
6 0 4

We have encountered two issues with changing product options after they have been created in certain circumstances. They could be related, however different errors are produced.

The first issue is removing the first option from an existing product that has two options. The remaining option is moved into the place of option one.

POST new product:

{
  "product": {
    "title": "Burton Custom Freestyle 151",
    "body_html": "<strong>Good snowboard!</strong>",
    "vendor": "Burton",
    "product_type": "Snowboard",
    "variants": [
      {
        "option1": "Small",
        "option2": "Red",
        "price": "10.00",
        "sku": "123"
      },
      {
        "option1": "Large",
        "option2": "Blue",
        "price": "20.00",
        "sku": "456"
      }
    ],
    "options": [
      {
        "name": "Size",
        "values": [
          "Small",
          "Large"
        ]
      },
      {
        "name": "Colour",
        "values": [
          "Red",
          "Blue"
        ]
      }
    ]
  }
}

PUT update to product, removing the size option:

{
  "product": {
    "title": "Burton Custom Freestyle 151",
    "body_html": "<strong>Good snowboard!</strong>",
    "vendor": "Burton",
    "product_type": "Snowboard",
    "variants": [
      {
        "option1": "Red",
        "price": "10.00",
        "sku": "123"
      },
      {
        "option1": "Blue",
        "price": "20.00",
        "sku": "456"
      }
    ],
    "options": [
      {
        "name": "Colour",
        "values": [
          "Red",
          "Blue"
        ]
      }
    ]
  }
}

Result:

{"errors": {"base": ["could not be saved successfully"]}}

The second issue is basically the opposite, when a product already has one option and a new option is added before the existing option. So option 1 moves to option 2, and the new option is inserted as option 1. This is necessary as our application always prioritises size over colour, but some products may initially have only a colour, and the size is then added later.

POST new product:

{"product":{"title":"Error adding option","variants":[{"price":20,"sku":"error1","option1":"Blue"},{"price":20,"sku":"error2","option1":"Red"}],"options":[{"name":"Colour","values":["Blue","Red"]}]}}

PUT product update, adding size option (replace XXXXXXXX with variant IDs):

{"product":{"vendor":null,"variants":[{"price":20,"sku":"error1","option1":"Small","option2":"Blue","id":XXXXXXXX},{"price":20,"sku":"error2","option1":"Large","option2":"Red","id":XXXXXXXX}],"options":[{"name":"Size","values":["Small","Large"]},{"name":"Colour","values":["Blue","Red"]}]}}

Result:

{"errors": {
   "options": ["is invalid"],
   "name": ["of Option is not unique"]
}}

However, the PUT request does work when the vendor field is removed (which we sometimes need to update simultaneously):

{"product":{"variants":[{"price":20,"sku":"error1","option1":"Small","option2":"Blue","id":XXXXXXXX},{"price":20,"sku":"error2","option1":"Large","option2":"Red","id":XXXXXXXX}],"options":[{"name":"Size","values":["Small","Large"]},{"name":"Colour","values":["Blue","Red"]}]}}

The PUT request also works when the options are in the original order, so the existing option remains as option1 and the new option is option2:

{"product":{"vendor":null,"variants":[{"price":20,"sku":"error1","option1":"Blue","option2":"Small","id":XXXXXXXX},{"price":20,"sku":"error2","option1":"Red","option2":"Large","id":XXXXXXXX}],"options":[{"name":"Colour","values":["Blue","Red"]},{"name":"Size","values":["Small","Large"]}]}}

If anyone is able to figure out what's going on here, that would be awesome.

2 Likes
Highlighted
Shopify Partner
3 0 1

Bump. Running into the same issues. Did you find a solution?

1 Like
Highlighted
Shopify Partner
5 0 0

Same issue here. Any solution or advice? Thanks

0 Likes
Highlighted
Shopify Partner
5 0 0

I tried something and it worked. Uptil now we know that something is wrong with Shopify API when we try to PUT (update) an existing product and moving the existing option to second position.

 

The existing product had one option called "Color" and a PUT request to add an option "Size" on the first position and more "Color" to second position resulted in the following response (422):

 

{"errors":{"options":["is invalid"],"name":["of Option is not unique"]}}

 

To work around this issue, I broke my request into two requests:

  1. In the first request, I added two options - "Size" and "Colour" (note that I changed the spelling of the "Color" option to "Colour")
    This request resulted in a 200 (success)
  2. In the second request, I made the same request as above, just changed the second option from "Colour" back to "Color"
    This request resulted in a 200 (success)

That's how I succeeded in achieving my goal. I hope this helps someone looking for an answer. Thanks.

0 Likes
Highlighted
Shopify Partner
23 0 2

Thanks for the workaround, but we really do need Shopify to report errors more specifically so that we can work with this in an automated way.

Shopify??

0 Likes
Highlighted
Tourist
4 0 1

I'm having a very similar issue, as exposed here. Can anyone tell me if the root cause has been found? 

0 Likes