productUpdateMedia doesn't work, no errors thrown

Topic summary

Problem: productUpdateMedia mutation returned media: null with no errors when trying to update image alt text on a product (even for an image just created via productCreateMedia).

Cause: The mutation was being called with a ProductImage ID instead of a MediaImage ID. ProductImage and MediaImage IDs are different; you cannot construct a valid MediaImage GID by simply changing the type in the GID (e.g., gid://shopify/ProductImage/… → gid://shopify/MediaImage/…).

Fix: Query the product to retrieve the MediaImage ID and use that in productUpdateMedia. Example approach: product { media { nodes { … on MediaImage { id, alt } } } } to obtain the correct MediaImage id, then pass that id to productUpdateMedia to update alt.

Status: Resolved. Screenshots illustrate the null response and the correct MediaImage ID highlighted for reference.

Summarized with AI on December 17. AI used: gpt-5.

I have 3 images in a product created with the REST product creation, and I want to update the “alt” property images with the productUpdateMedia mutation, but it doesn’t work. Following the request and the response:

note the “media : null” in the response.

Curiously, if I try to use the productCreateMedia the operation work fine:

Then I tried to update, with the productUpdateMedia mutation, this new image created with productCreateMedia, and the operation still doesn’t work.

Have you any idea to solve this problem?

Thank you.

It was simple…

The image id variable is a ProductImage id, not a MediaImage id. It’s not possible get the number of the ProductImage and build the MediaImage.

Example

if the image id is 0123456789 I can build the gid product image in this way:
gid://shopify/ProductImage/0123456789

but if I need to refer to the media image I cannot build it like:

gid://shopify/MediaImage/0123456789

The media image will be different, to discover it it is necessary query the product and catch it, like something of the following:

the id hightlighted in red is the MediaImage, this is to be used for productUpdateMedia mutation.