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

Anthony28
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.

Replies 9 (9)
protractorgod
Shopify Partner
3 0 1

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

Hemant_Arora
Shopify Partner
5 0 4

Same issue here. Any solution or advice? Thanks

Hemant_Arora
Shopify Partner
5 0 4

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.

Hgolov
Shopify Partner
26 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??

rodrigosqquid
Tourist
4 0 3

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

stickfigure
Shopify Partner
37 2 5

Two years later and I'm seeing the same issue as the OP. Guess I'll have to resort to the two-step change. 

rknell
New Member
1 0 0

Just started happening for me too. Maybe something changed?

Paderborn
Tourist
13 0 0

Same issues happen😂,why options can not edit easy。。。what i want is add size later or remove size option when necessary

Paderborn
Tourist
13 0 0

lost me many many time to find a solution delete size option😁

fortunately I find it

1、What option you want remove must is last option,so if you want remove first you should reorder option

2、What option you want remove the value in variants must be same and can not be "Default Title"