Solved

Sudden Liquid Error with no updates. Expected input to be a String but got Metafields::StringDrop

Alex-EI
Tourist
3 0 3

My site had suddenly started throwing an error, despite no updates to my code base. 

The error says:

Expected input to be a String but got Metafields::StringDrop

The line in which the error is occurring is in a snippet called team-badge

 

{{ rotator_image | asset_url | img_tag: "", 'badge-rotator-img'}}

 

The snippet above is called by a  section file with the following line:

 

{%- render 'team-badge', rotator_image: collection.metafields.global.treasure_badge_asset, badge_url: collection.metafields.global.treasure_badge_url -%}

 

 

We use this team-badge throughout the site. The error only occurs when using the metafields.

I've tried Googleing the error, however, the only pages that pop up belong to our site! So, I'm not finding any help in the Googel-verse. "Metafields::StringDrop" isn't anywhere I can find either. 

Again, this is an error which did not exist, and then without any updates, started appearing. 

Any help would be greatly appreciated. 

Accepted Solution (1)

MetafieldsGuru
Shopify Partner
158 32 96

This is an accepted solution.

Hi Alex,

 

Sasha here from Metafields Guru team.

 

I've been contacted by another Shopify merchant experiencing a similar issue earlier. Luckily, I managed to figure out what exactly caused the error and how to get it fixed.

The reason for this error is the recent update in Shopify Liquid. The "old" version of Liquid would require a code like this to retrieve a metafield value:

{{ resource.metafields.namespace.key }}

The same code would return a metafield object in the "new" version of Liquid. And that's where the issue comes from. Since your theme uses "old" Liquid code, it returns an object while the Liquid filters (the URL filter, in this case) expect the variable passed to be a string.

So, in order to have the issue resolved, you may want to update your Liquid code and use the proper syntax of "new" Liquid standard:

{{ resource.metafields.namespace.key.value }}

Note that ".value" part added after the metafield key. As we're dealing with the object, it helps us to retrieve the metafield value and pass it as a variable for the URL filter.

 

Hope this helps!

 

A message to other Shopify merchants looking to have a similar issue resolved: if you don't know how to use Liquid or customize your theme, don't worry. In this case, you may want to consider contacting a developer who has set up the store for you and asking them to update your store's theme code.

Check out Metafields Guru, the #1 ranked metafields app.

Bulk editor | Data import/export | Metafield sets | Browser extension

View solution in original post

Replies 6 (6)

drakedev
Shopify Partner
685 148 230

Are using an app to manage the metafields?

If you didn't change anything metafields related in your code, could be that the app your are using have been updated and maybe it is the reason of this error.

If my answer was helpful click Like to say thanks
If the problem is solved remember to click Accept Solution
Shopify/Shopify Plus custom development: You can hire me for simple and/or complex tasks.

MetafieldsGuru
Shopify Partner
158 32 96

This is an accepted solution.

Hi Alex,

 

Sasha here from Metafields Guru team.

 

I've been contacted by another Shopify merchant experiencing a similar issue earlier. Luckily, I managed to figure out what exactly caused the error and how to get it fixed.

The reason for this error is the recent update in Shopify Liquid. The "old" version of Liquid would require a code like this to retrieve a metafield value:

{{ resource.metafields.namespace.key }}

The same code would return a metafield object in the "new" version of Liquid. And that's where the issue comes from. Since your theme uses "old" Liquid code, it returns an object while the Liquid filters (the URL filter, in this case) expect the variable passed to be a string.

So, in order to have the issue resolved, you may want to update your Liquid code and use the proper syntax of "new" Liquid standard:

{{ resource.metafields.namespace.key.value }}

Note that ".value" part added after the metafield key. As we're dealing with the object, it helps us to retrieve the metafield value and pass it as a variable for the URL filter.

 

Hope this helps!

 

A message to other Shopify merchants looking to have a similar issue resolved: if you don't know how to use Liquid or customize your theme, don't worry. In this case, you may want to consider contacting a developer who has set up the store for you and asking them to update your store's theme code.

Check out Metafields Guru, the #1 ranked metafields app.

Bulk editor | Data import/export | Metafield sets | Browser extension
Alex-EI
Tourist
3 0 3

@MetafieldsGuru That was exactly my problem, thank you so much!!

quartzstudio
Visitor
2 0 0

Thanks! This solved the problem.

How do I get notified of fundamental changes to languages like Liquid? I can't see any mention of this in the changelog linked.

Alex-EI
Tourist
3 0 3

@quartzstudio you can see changes to the Shopify platform here: https://shopify.dev/changelog

It lets you enter an email so you can be updated when there's a change.

MetafieldsGuru
Shopify Partner
158 32 96

Hi guys!

 

Sorry for a late reply, I didn't see the notifications for some reason.

It's really nice to hear that my reply helped you to resolve the same issue on your stores 😁

 

Best regards,

Sasha Kachkovskyi

Co-founder and CEO
256 Development
Check out Metafields Guru, the #1 ranked metafields app.

Bulk editor | Data import/export | Metafield sets | Browser extension