Unable to set metafields via productVariantsBulkUpdate - Value must be a file reference string

I’m trying to update metafields on product variants via the productVariantsBulkUpdate mutation and it returns error “Value must be a file reference string”

  • the mutation has worked in the past
  • doesn’t occur on all stores
  • the metafield is a ‘single_line_text_field’ and error occurs whether a metafield definition is created or not
  • the existing value is a string, the new value is also a string
  • error does not occur when using metafieldSet mutation

Anyone else encountered such an error?

Example:

metafieldsSet is okay

Hey @Min_Liu - this does seem odd for sure. I checked some things on our end and I couldn’t connect the error to any changes on our side, but I’m happy to dig into this. Could you send me an x-request-id from an example of the failure you’re seeing?

The x-request-id would be in the response header for the API call - if you’re using Postman or another API platform, these are usually in the headers tab in the response section there.

Hope to hear from you soon - I can definitely look into our logs here for you.

Hi @Alan_G

X-Request-ID is 1d3f8a5b-d32f-459c-b279-f90a6e7d5a9c-1778282024

Thanks

Hey @Min_Liu - thanks for sending that over.

I took a look at that request ID, and the specific shipping.height variant metafield you’re updating does look correctly set up as a single_line_text_field, so I don’t think your input for that metafield is the issue here.

One thing I did notice is that there appears to be another file-reference metafield on the product itself. With productVariantsBulkUpdate, invalid existing metafield values on the product/variant can sometimes surface during the variant update even if the mutation isn’t directly trying to update that metafield. Not super ideal, but that would line up with the error you’re seeing here.

For now, I’d suggest checking the product’s existing file-reference metafield value and either correcting or clearing it, then retrying the productVariantsBulkUpdate call. Using metafieldsSet for the variant metafield update is also a good workaround in the meantime, since that mutation is scoped directly to the metafield value being set.

Let me know if you’re still seeing the error after checking that product-level metafield, and I can keep digging on our end here.

Cheers thanks,

The file reference metafield isn’t related to the app, and whilst it may be incorrect i don’t think it should affect other apps trying to update other metafields.

The reason why we don’t use the metafieldsSet mutation is due to the update limit on the mutation.

I will check out the file reference metafield with the store owner and see if they can fix that.

No worries - feel free to ping me here if you’re still encountering issues and I can help out as always :slight_smile: