productVariantsBulkUpdate API fails due to unrelated invalid metafields

Currently, the productVariantsBulkUpdate API fails when a product variant contains an invalid metafield value, even when the requested update doesn’t involve modifying the metafield or metafield value itself. For example, attempting to update a product variant’s price may still fail due to an unrelated invalid metafield value.

Example error message:

Value does not exist in provided choices: [\"a\", \"b\", \"c\"]

Could we please adjust the API to only validate metafields when they are explicitly being updated? This would prevent unrelated updates (e.g., price changes) from failing due to pre-existing metafield issues (unrelated to the API caller).

1 Like

Hey @thl

Does the error still show when you set allowPartialUpdates to true?

When partial updates are allowed, valid variant changes may be persisted even if some of the variants updated have invalid data and cannot be persisted. When partial updates are not allowed, any error will prevent all variants from updating.

Hi @KyleG-Shopify,

Yes, the error still shows when allowPartialUpdates is set to true.

To clarify, I expect the price change to persist for the product variant with pre-existing invalid metafield data, given that the productVariantsBulkUpdate API call only modifies the price and doesn’t attempt to update any metafield values.

I would expect an error only if the API call tried to update the metafield with an invalid value.

Interesting. Thanks for confirming that. Do you by chance have an x-request-id from a response that returned this error?

@KyleG-Shopify "x-request-id": "1cb9e98a-fa13-40b7-8238-409e1d7c77cf-1746816288"

Thank you so much. Just another question, are you able to update the item in the admin, or does that return errors as well? The reason I ask is to see if this is specific to the mutation or maybe the product variant itself.

@KyleG-Shopify It also fails in the admin if you change an unrelated field (e.g. price).

Error in Shopify admin:

I think it makes sense for the admin to fail in this case since the variant edit page includes metafields at the bottom.

However, I think the API should not fail if it is only attempting to update an unrelated field (e.g. price).

Thanks so much for testing that.

I did some further digging and found this is a known issue/concern at the moment when updating unrelated fields. Our team is looking in to ways to improve this. I’ll be sure they see this post as well for an additional example.

Currently, the workaround would be to update the metafields or the definition so this error doesn’t occur. Most likely the definition was updated with some values removed so the current values on the variant are no longer valid, leading to the error.

I don’t have a timeline on a resolution, but I’ll keep my eyes on it and update here with any changes.