Cannot change metaobject field type via app configuration — “existing metafield definition” error persists even after removing the field

Problem

I’m trying to change a field on a metaobject definition that is managed by my app’s shopify.app.toml configuration. For example, suppose I have the following definition:

[metaobjects.app.author.fields] 
name = { name = "name", type = "single_line_text_field", required = true } 
comment = { name = "comment", type = "single_line_text_field", required = true } ​

I want to change the comment field from single_line_text_field to a different type (e.g. multi_line_text_field or a metaobject_reference).

When I update the toml and run shopify app deploy, I get the following error:

Version couldn’t be created.

[metaobjects.app.author.fields.comment] Cannot change type of existing metafield definition - type: single_line_text_field

What I tried

I understand that Shopify does not allow changing the type of an existing metafield/metaobject field definition in place, so I tried a workaround:

  1. Remove the comment field entirely from the toml and deploy a new app version.
  2. Re-add the field with the new type and deploy again.

However, step 2 still fails with the same error referring to existing metafield definition - type: single_line_text_field. This is confusing, because after step 1 I would expect the old field definition to no longer exist — yet the deploy is still treating it as if the old single_line_text_field definition is still there.

I also tried deleting the metaobject definition directly via the Admin GraphQL API using metaobjectDefinitionDelete, but it returns the following error.

  "data": {
    "metaobjectDefinitionDelete": {
      "deletedId": null,
      "userErrors": [
        {
          "field": [
            "id"
          ],
          "message": "Definition is managed by app configuration and cannot be modified through the API.",
          "code": "APP_CONFIG_MANAGED"
        }
      ]
    }
  }

My questions:

  1. Why does the deploy still complain about an “existing metafield definition” of type single_line_text_field even after I removed the field from the toml and deployed successfully? Does removing a field from the toml not actually delete the underlying definition?
  2. What is the correct procedure to change the type of a field on an app-managed metaobject definition? Is there any supported way (CLI command, API, or Partner Dashboard action) to drop the old field/definition so I can recreate it with a new type?
  3. If the only path is to recreate the metaobject definition under a new key (e.g. author_v2) and migrate data, could you confirm that?

BTW: I think this is somewhat related to https://community.shopify.dev/t/cannot-change-app-metafield-type-from-number-integer-to-single-line-text-field-how-to-delete-and-recreate/26521

1 Like

Hey @shunten31 - thanks for reaching out. Looking into this on my end here, I’ll loop back with you once I can confirm expected behaviour for you :slight_smile:

1 Like