useApplyMetafieldsChange fails to update silently

Topic summary

A bug has been identified in Shopify’s Checkout UI Extensions where useApplyMetafieldsChange fails to properly update order metafields when a value already exists.

Key Issue:

  • The API returns a false positive success response even when the metafield update actually fails
  • No error is thrown despite the update not being applied
  • The promise resolves successfully, but the metafield value remains unchanged

Example Behavior:

  • When attempting to update a metafield (e.g., real_id.check_id) to a new value like “bbbbbbb”
  • Console logs show “Updated” message with the new value
  • However, checking the actual metafield reveals it still contains the old value (“aaaaaaa”)

Status:
The reporter has filed an official bug report in the Shopify UI Extensions GitHub repository (issue #1912) and is seeking clarification on whether a special “force update” flag is needed as a workaround.

Summarized with AI on November 9. AI used: claude-sonnet-4-5-20250929.

Hello,

We’ve noticed a bug with attempting to apply order metafields in Checkout UI Extensions.

Applying a metafield change during checkout where a metafield value is already present will result in a false positive result.

Here’s a snippet of example code:


applyMetafieldsChange({
type: "updateMetafield",
key: "check_id",
namespace: "real_id",
value: check.id,
valueType: "string",
})
.then(() => {
console.log("Updated real_id.check_id metafield to : ", check.id);
console.log(
"Result: ",
metafields.find((mf) => mf.key == "check_id")?.value
);
})
.catch((e) => {
console.error(`Failed to update metafield`);
console.error(e);
});

If check_id in this example is bbbbbbb for example, then you’d expect the result to be bbbbbbb. Yet, we’re seeing this strange output from this code above:

Updated real_id.check_id metafield to : bbbbbbb
Result: aaaaaaa

It appears the applyMetafieldsChange doesn’t actually properly update the metafield nor does it throw an error in this case when the update failed.

Is there a special flag that needs to be passed to “force” an update?

2 Likes

I’ve also created a bug report on the Shopify UI Extensions Github Repository.

Here’s a link to the issue: https://github.com/Shopify/ui-extensions/issues/1912

1 Like