Unable to set a file_reference metafield to an EXTERNAL_VIDEO file

Hello,

When I try to set a file_reference metafield to a value like gid://shopify/ExternalVideo/28048706568273 I get the following error: Value must be a file reference string but elsewhere in the API external videos are treated like files and they implement the File interface.

You can reproduce the error by choosing a file to reference in the admin and selecting an external video:

The following GraphQL query also returns the same error:

mutation {
  metafieldsSet(metafields: [
    {
      key: "file_reference",
      namespace: "my_fields",
      ownerId: "gid://shopify/Product/7744832176209",
      type: "file_reference",
      value: "gid://shopify/ExternalVideo/28048706568273"
    },
  ]) {
    metafields {
      key
      namespace
      value
      createdAt
      updatedAt
    }
    userErrors {
      field
      message
      code
    }
  }
}

One partial workaround when using the GraphQL API is to refer to the external video as a GenericFile instead. For example passing gid://shopify/GenericFile/28048706568273 instead of gid://shopify/ExternalVideo/28048706568273. In my tests this appears to work on the storefront with the external_video media tag.

This isn’t ideal though because it breaks the display in the Shopify admin. You can’t tell what file is connected and users can think that it’s broken:

Unable to see video details in admin

Does anyone have any other ideas how make the file_reference metafields work better with external videos?

Thanks,
Daniel

Hi Daniel,

Thanks for flagging and providing the examples you’ve described. It does look like this could be a limitation on our side - I’m connecting with the product team on this to get their recommendation.

1 Like