Line item key changing if add/update/delete multiple products at same request with CART API

Topic summary

Developers reported that Shopify’s Cart API was unexpectedly changing line item keys when adding, updating, or deleting multiple products in a single request. The key would change after the second request but remain stable afterward, breaking functionality like item removal and quantity updates.

Core Issue:

  • Line item keys changed inconsistently during cart operations
  • Affected /cart/add.js, /cart/update.js, and /cart/change.js endpoints
  • Caused “no valid id or line parameter” errors when attempting to remove items
  • Page refresh would correct the keys, suggesting a server-side synchronization problem

Impact:

  • Remove links generated by {{item.url_to_remove}} failed until page refresh
  • Cart drawer/side cart implementations showed duplicate line items instead of merged quantities
  • Discount application/removal also triggered key changes

Resolution:
Shopify Support confirmed and fixed the bug after being contacted through their partner support channel. Multiple users verified the fix is working.

Additional Finding:
One developer discovered that passing boolean values as strings in line item properties can still cause key mismatches, as Shopify converts them to actual booleans server-side, creating temporary hash differences until the page refreshes.

Summarized with AI on October 29. AI used: claude-sonnet-4-5-20250929.

Hi Darren,

I just checked a couple of my stores and the keys seem to be consistent even when the quantity is updated. Could you please check again or provide me your store url so that I can check once.

Thank you.

  • Kaustuv