Trying to add images to metafields in shopify workflow, need file reference string for my images

Topic summary

Goal: Automate setting a product metafield to an image using Shopify Flow, but Flow errors with “Value must be a file reference string.”

Key details:

  • The metafield must store a file reference to an image (GID format like gid://shopify/MediaImage/123…). Filenames (e.g., barbecue-128.png) are invalid.
  • “Metafields” = custom fields on Shopify resources. “Shopify Flow” = automation tool. “GID” = Shopify’s global identifier.

Troubleshooting and findings:

  • Images uploaded under Content > Files have MediaImage GIDs. You can fetch them via Admin GraphQL (GraphiQL app): query files { nodes { … on MediaImage { id } } }.
  • Ensure the metafield definition is set to File > Image (not GenericFile). Remove surrounding quotes in Flow and avoid whitespace.
  • “Value references non-existent resource” indicates a wrong or mismatched GID.

Working solution (final):

  • Add the desired image to any product’s target metafield once using the bulk editor.
  • In bulk editor, copy the metafield cell (Ctrl+C) to get the correct, store-wide MediaImage GID.
  • Use that GID in Shopify Flow to set the metafield across products.

Artifacts: Screenshots were shared (workflow/settings). A GraphQL code snippet was central.

Status: Resolved. The bulk editor copy method provides the correct file reference string for Flow automation.

Summarized with AI on January 27. AI used: gpt-5.

It’s not a typical use case, but probably 50% of use cases on Flow are custom in some way. That’s why Flow exists.

This is still your error?

"Got error updating metafield: “Value must be a file reference string.”

I just tested this in my store and was able to update a product metafield with a file reference type using an image from that Content section (with the gid string). Therefore, I suspect that your metafield is not set up to accept images. I see that by default it accepts “GenericFile” or something like that.

Here are my settings

1 Like