Graph QL Files Update Media Image Not Working

Topic summary

Updating media images via Shopify Admin GraphQL fileUpdate fails when using originalSource, returning: “Variable $files of type [FileUpdateInput!]! was provided invalid value for 0.originalSource (Field is not defined on FileUpdateInput).” Other operations (create, delete, update altText) work.

  • Cause/fix: The correct input field is previewImageSource, not originalSource, contrary to the referenced docs example.
  • Version note: A Shopify staff member says on API version 2023-07+ both originalSource and previewImageSource should work. The reporter says originalSource still failed for them on 2023-07, while previewImageSource worked.
  • Documentation status: Shopify acknowledged the doc issue and escalated to the documentation team. As of 2024-01-15, the docs still show originalSource; community confirms previewImageSource is correct.

Outcome: Reliable workaround is to use previewImageSource to update the image data. Disagreement remains about originalSource behavior on 2023-07+.

Status: Partially resolved (workaround identified). Documentation correction and definitive behavior across versions remain pending.

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

Hi, I’ve followed the docs exactly:

https://shopify.dev/docs/api/admin-graphql/2023-01/mutations/fileUpdate#examples-Update_an_image

I keep getting this error message:

Variable $files of type [FileUpdateInput!]! was provided invalid value for 0.originalSource (Field is not defined on FileUpdateInput)

Here’s the general code:

$files = [
            "files" => [
                "id" => $id,
                "originalSource" => $url
            ]
        ];

$queryString = <<

Anybody know why it keeps saying **invalid value for 0.originalSource (Field is not defined on FileUpdateInput)??**

I have no problems adding new photos, and delete existing ones, I simply can't update existing photos with new image data (I am able to update the ALT text without issue).

Someone should update the docs!

The correct value is “previewImageSource” not "originalSource"

Hey @Jason27 thanks for flagging that issue with our documentation and identifying a fix! I’ve let our documentation team know.

In testing this as well, version 2023-07 and higher, the originalSource OR previewImageSource both will work if you want to move up to that version.

Hope that helps,

Kyle G.

1 Like

I swear I testedoriginalSource on 2023-07 and it did not work, but I found previewImageSource worked for sure. In any case, thanks for the responsiveness! Appreciated :slightly_smiling_face:

1 Like

As of 1-15-24, the doc still says originalSource , but should be previewImageSource … right? jb

Correct

1 Like