Metaobject definition TOML error

I’m trying to use declarative TOML metaobject definitions. The goal is to create a metafield definition that has a metaobject_reference field.

I get the following error on deploy:

Version couldn’t be created.
[metaobjects.app.item.fields.render] Validations must be a valid metaobject definition belonging to your shop.

However, the metaobject definition is valid and available on the dev store.

Here is my TOML config:

[metaobjects.app.item]
name = “Item”
access.admin = “merchant_read_write”
access.storefront = “public_read”

[metaobjects.app.item.fields.title]
name = “Title”
type = “single_line_text_field”

[metaobjects.app.item.fields.render]
name = “Render”
type = “metaobject_reference”
validations = {metaobject_definition_id = “gid://shopify/MetaobjectDefinition/11263082609”}

[metaobjects.app.render]
name = “Render”
access.admin = “merchant_read_write”
access.storefront = “public_read”

[metaobjects.app.render.fields.title]
name = “Title”
type = “single_line_text_field”

The metaobject definition ID, gid://shopify/MetaobjectDefinition/11263082609, is correct. Ive atached a screenshot with the query response.

What am I missing?

1 Like

Hi @Mircea_Piturca,

It looks like this error might be occurring due to the way you are declaring the validations in the toml file.

instead of declaring it like:

validations = {metaobject_definition_id = “gid://shopify/MetaobjectDefinition/11263082609”}

They should be declared with a JSON object with the name and value fields in an array, like so:

validations = [{name = "metaobject_definition_id", value = "gid://shopify/MetaobjectDefinition/123"}]

There’s an example in the Validation Options documentation that discusses this further:

If you’re still getting the error after updating the configuration with the above, and deploying a fresh version, please add the --verbose flag to the app deploy command, and provide us with the output for us to help look into further (censoring any access tokens or credentials that may be listed in the output, the important thing we’re looking for here is the error messages and x-request-ids)

@Kellan-Shopify Thank you for your suggestion; however, this doesn’t seem to be a valid TOML:

[metaobjects.app.devtest]
name = “Dev test”
access.admin = “merchant_read_write”
access.storefront = “public_read”

[metaobjects.app.devtest.fields.render]
name = “Some field”
type = “metaobject_reference”
validations = [{name = “metaobject_definition_id”, value = “gid://shopify/MetaobjectDefinition/11263082609”}]

This will give:

App configuration is not valid. Validation errors in shopify.app.development.toml:
[metaobjects.app.devtest.fields.render]: Invalid input.

I think the link you mentioned only covers API call validations. I wasn’t able to find a TOML example with a metaobject reference.

Hi @Mircea_Piturca,

Thanks for trying that and confirming it didn’t work. It does appear that the previous syntax you were using is more correct based on the errors you’re seeing, though I’m currently looking into this with our developers internally to confirm the correct way to declare metaobject validations in the toml file.

I feel like this is due to the fact that these are declarative metaobjects so when you deploy the app and it creates the metaobject definitions, it’s not done with the context of the actual store that the validation metaobject definition exists on, like it would have been if done via an API call.

As mentioned I’m currently discussing this with our developers further, though I might not hear back until monday at this point.

In the meantime, can you revert back to the previous syntax you were using that returned the Validations must be a valid metaobject definition belonging to your shop error, and then apply the --verbose flag, replicate this error once more, and provide us with the output (not including any tokens or credentials in the output)