Re: Internal Server Error when retrieving MediaImage from Metafield in Storefront API

Solved

Internal Server Error when retrieving MediaImage from Metafield in Storefront API

es_beto
Tourist
8 1 0

Hello!

I'm developing a store with the Storefront API using the js-buy-sdk and we're having issues retrieving an Image src from a MetaField.

I'm getting an internal server error:

 

[
  {
    "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: 97995dfd-f5ab-4f41-8f73-e833fea39364 (include this in support requests).",
    "extensions": {
      "code": "INTERNAL_SERVER_ERROR",
      "requestId": "97995dfd-f5ab-4f41-8f73-e833fea39364"
    }
  }
]

 

Context:

First, we fetch the product details with the MetaField like so:

 

// from a productByHandle query
// ...
product.add(
    'metafield',
    {
        alias: 'size_chart',
        args: {
            key: 'size_chart',
            namespace: 'details',
        },
    },
    (metafield) => {
        metafield.add('key')
        metafield.add('value')
    }
)
// ...

 

This works, but it returns a global file id:

 

{
  "id": "Z2lkOi8vc2hvcGlmeS9NZXRhZmllbGQvMTk4MjEzMjU1NDk3NDE=",
  "key": "size_chart",
  "value": "gid://shopify/MediaImage/22086478004397"
}

 

 Now I've tried many things, the furthest I've reached is trying to fetch the image src with a node query, but I'm getting the error above

My imageQuery looks like this:

 

const imageQuery = client.graphQLClient.query((root) => {
  root.add(
    "node",
    {
      args: { id },
    },
    (node) => {
      node.addInlineFragmentOn("MediaImage", (mediaImage) => {
        mediaImage.add("image", (image) => {
          image.add("originalSrc", { alias: "src" });
          image.add("altText");
        });
      });
    }
  );
});

const { model, errors } = await client.graphQLClient.send(imageQuery);

 

I've tried encoding the "gid://..." id with both window.btoa(size_chart.value) and Buffer.from(size_chart.value).toString('base64') with no luck

Please help! Thanks a lot!

Accepted Solution (1)
es_beto
Tourist
8 1 0

This is an accepted solution.

What we ended up doing:

Instead of using the Metafield type as file, we changed it to type string.

We upload the media file and place the url in the Metafield.

Then we were able to use it with the Storefront API.

 

View solution in original post

Replies 10 (10)

Jayvin
Shopify Partner
284 42 89

Hi,

These are errors on shopify side

Internal error. Looks like something went wrong on our end

 Try again, it should work.

banned
es_beto
Tourist
8 1 0

Tried again, still getting Internal Server Error, new id:

{
  "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: 11238932-67a7-4f70-a54a-f64111b324c0 (include this in support requests).",
  "extensions": {
    "code": "INTERNAL_SERVER_ERROR",
    "requestId": "11238932-67a7-4f70-a54a-f64111b324c0"
  }
}
es_beto
Tourist
8 1 0

Still getting Internal Server Errors.

message: "Internal error. Looks like something went wrong on our end.
Request ID: 604cbd25-4879-4426-90f4-31b6faaa42d4 (include this in support requests)."
es_beto
Tourist
8 1 0

Still getting Internal Server Errors:

{
  "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: eea00a18-a9c1-41ce-b144-ae2e3f77604e (include this in support requests).",
  "extensions": {
    "code": "INTERNAL_SERVER_ERROR",
    "requestId": "eea00a18-a9c1-41ce-b144-ae2e3f77604e"
  }
}
es_beto
Tourist
8 1 0

Still getting Internal Server Error

{
  "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: 3001bfeb-4829-473d-bea7-e1ad1924addf (include this in support requests).",
  "extensions": {
    "code": "INTERNAL_SERVER_ERROR",
    "requestId": "3001bfeb-4829-473d-bea7-e1ad1924addf"
  }
}
es_beto
Tourist
8 1 0

Still getting Internal Server Error (2020-08-22)

{
  "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: d0b5d258-96a6-43e2-b2d1-895b9cc1fc8b (include this in support requests).",
  "extensions": {
    "code": "INTERNAL_SERVER_ERROR",
    "requestId": "d0b5d258-96a6-43e2-b2d1-895b9cc1fc8b"
  }
}

 

Jayvin
Shopify Partner
284 42 89

Hi,

Seems like you are still stuck on this issue. Contact shopify support. They will help you out.

banned
es_beto
Tourist
8 1 0

Thanks for the reply, will do that.

chris__m
Shopify Partner
2 0 1

I have the same issue when I try to reach the file using "Shopify GraphiQL App", API schema: Storefront:

 

query {
  node(id:"MY_MEDIA_ID") {
    __typename
  }
}
{
  "errors": [
    {
      "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: a9bb5a6f-f8fe-42be-8fdb-dc7a1b3f6a99 (include this in support requests).",
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "requestId": "a9bb5a6f-f8fe-42be-8fdb-dc7a1b3f6a99"
      }
    }
  ]
}

 

I've found out that it's related to Storefront API access to files.
When you try to reach this id using Admin API schema you'll a good value.

 It's really strange that you can get the ID to media by Storefront API, but you cannot reach this media at all.

es_beto
Tourist
8 1 0

This is an accepted solution.

What we ended up doing:

Instead of using the Metafield type as file, we changed it to type string.

We upload the media file and place the url in the Metafield.

Then we were able to use it with the Storefront API.