Unexpected change to cart.js error responses, breaking functionality

I’ve had some cart validation functions in my public app successfully running for some time, with no recent changes made.

Today it was noticed that when there are function errors, the response from cart JSON API, is like so:

{status: 422, message: "Cart Error", description: "You can't remove this item from the cart"}

My code has always looked at the message property for the actual error message, which can then be acted on or displayed on the front-end, not the description property.

It seems like the behaviour here has changed, unexpectedly.

This is backed up, because even Dawn theme would show the descriptive error message previously when there were failed updates on the Cart. Now it just shows “Cart Error” - i.e. the message property. Handling of this is built into the theme, not my code.

In fact, the response from /cart/changes, when updating the quantity in the cart is only this…

{errors: "Cart Error"}

… which is clearly not the error message being provided by the cart-validation function.

My function is returning the message using the localizedMessage prop, like so:

{
   localizedMessage: "You can't remove this item from the cart",
   target: `$.cart.lines[?(@.id=='${line.id}')]`,
}

I don’t see any other way to do it or any different props I should be using for the descriptive error message.

I can easily update the handling of the response in my app block, but this won’t help with /cart/change errors. In most themes, customers will only see a basic "Cart Error" displayed for every function error.

Anyone else noticed a change in the behaviour here?

Thanks!

1 Like

It looks like Shopify reversed this change.

I now get this again:

{"status":422,"message":"You can't remove this item from the cart","description":null}

Funnily enough, even though this was the previous behaviour, it doesn’t actually align with the docs.

The docs are aligned with the temporary change that was observed, but is no longer.

It shows that the message should always be “Cart Error” and the description should be the meaningful explanation.

Would be good to get some clarification from the team.

@Liam-Shopify

Hey @gunner - taking a look into this, thanks for flagging. This does seem similar to some other reports I’ve seen:

I’ll loop back with you here once I have next steps.

Hi folks, just following up here. There has been some further movement on this and we are working on a fix. I still can’t guarantee an exact turnaround time, but just wanted to keep you all in the loop - thanks again for your patience on this.

Hey @Alan_G

Thanks for looking into it.

I’m not sure a fix is needed any more. The change appears to have been reverted to the original behaviour as I mentioned above. This is the same behaviour I’ve seen for at least the last 9 months.

Any change to align with the docs will likely break apps and themes, as it did when the temporary change was made ~5 days ago.

Thanks @gunner - I’ll pass along your feedback to the team and loop back with you here if I can share any other info, really appreciate your followup on this!

Hello @Alan_G -san
Is there any update on this issue? Thank you in advance for your help.

Hi @azy :waving_hand: , thanks for reaching back out, really appreciate your patience on this. I still can’t share when a fix will be released for this, but I can share that work is being done to address the issue on our product team’s side. I’ll look into this further to see if we can share more specific information with you though, appreciate you reaching back out for sure.

1 Like

Hey all, just following up here :waving_hand: - I believe a fix has been pushed for this. Could you let me know if the issue is still persisting and if so, I’ll prioritize looking into this: