App-data metafield - INTERNAL_ERROR

Need some assistance with creating app-data metafields. I am following the guide, but when I attempt to store data with metafieldsSet , I get an INTERNAL_ERROR code and message Unexpected system error. Try again later.

Here is the mutation and the response:

Mutation

let mfSet = await client.request(
    `
    mutation saveBundleId($input: [MetafieldsSetInput!]!) {
      metafieldsSet(metafields: $input) {
        metafields {
          id
          namespace
          key
        }
        userErrors {
          code
          elementIndex
          field
          message
        }
      }
    }`,
    {
      variables: {
        input: [
          {
            key: <keyName>,
            ownerId: <appInstallationId>,
            type: "single_line_text_field",
            value: "testing..."
          }
        ]
      }
    }
  )

Response

{
  "data": {
    "metafieldsSet": {
      "metafields": [],
      "userErrors": [
        {
          "code": "INTERNAL_ERROR",
          "elementIndex": null,
          "field": [
            "metafields",
            "0"
          ],
          "message": "Unexpected system error. Try again later."
        }
      ]
    }
  }
}

Any assistance would be greatly appreciated.

FYI… I created a support ticket 53507851, but have to receive any updates.

Hi Steve,

Checking with the custom data team if there’s an issue with our docs on this - and why you might be seeing this issue.

LIam,

Thank you for the reply.

In troubleshooting this issue on my own, I discovered that if I manually specify a namespace, then the metafieldsSet mutation works without any errors. I discovered this as the example in the guide shows a namespace as part of the mutation input variables.

However, looking at the documentation for metafieldsSet, the MetafieldsSetInput object shows a namespace field with the following comment:

The container for a group of metafields that the metafield is or will be associated with. Used in tandem with key to lookup a metafield on a resource, preventing conflicts with other metafields with the same key. If omitted the app-reserved namespace will be used.

For this reason, I omitted the namespace as part of input, but unfortunately this is what seems to have caused the INTERNAL_ERROR. I would prefer the namespace be the app-reserved namespace as opposed to manually specifying a namespace in the metafieldsSet mutation.

Please confirm if this is a documentation error or a bug with the metafieldsSet mutation.

…As an aside, I replied to the support ticket with the same findings, yet never received a reply. What is the point of having an API support channel if there is no timely response? Is this forum the preferred support channel for GraphQL/API related issues?

Can you share a request ID so our team can dig into this a bit more?

Regarding your variables in the mutation:

{
      variables: {
        input: [
          {
            key: <keyName>,
            ownerId: <appInstallationId>,
            type: "single_line_text_field",
            value: "testing..."
          }
        ]
      }
    }
  )

Our team said:

ownerId is the shopify gid of the resource, not the app ID (the example in the docs is " gid://shopify/Product/20995642 "), you don’t need to pass your app ID as we know this already whenever you make a request

Liam,

Thank you for the update.

If you look at the the example in Step of the guide, you will see the appInstallationId is used for the ownerId, as this is an app-data metafield, not a “standard” metafield (product, variant, order, etc…) The example also specifies a namespace, where I was omitting the namespace in order to use the app-reserved namespace.

I just ran the metafieldsSet mutation again, omitting the namespace, and received the same INTERNAL_ERROR with message "Unexpected system error. Try again later."

The X-Request-Id for this request is 8df2fa81-3f82-4516-8e83-d2c8d112151d-1737388994, timestamp Mon, 20 Jan 2025 16: 03: 14 GMT

Thanks for sharing the request ID - connecting with the custom data team on this again!

@Liam-Shopify Any update from the custom data team?

Hey Steve - will re-connect with them on this!

@Liam-Shopify Any updates?

Hi Steve,

Our team recently pushed an update allowing app data metafields to use their default app-reserved namespace, which should fix the internal error you were encountering. Let me know if you’re still seeing this issue.

@Liam-Shopify Thanks for the update. I just did another test and unfortunately the same error persists. The new Request ID is a5066846-d89b-4c47-a1d6-bca725c489e2-1738689952

Please follow up with the custom data team. Please provide regular updates.