Line_item.key mismatch between Liquid and cart/change.js response when cart discount level automatic discount is applied

Short description of issue

Inconsistency between Liquid line_item.key and the Ajax API cart/change.js response items[‘key’]

Link to Shopify Store

Reproduction steps

  1. Add a product to the cart.
  2. Open the mini cart.
  3. Update the quantity → works fine. The key in Liquid matches the key in the cart/change.js response.
  4. Create an automatic discount at the cart discount level in the Shopify admin, and make it trigger for the current cart.
  5. Update the quantity → the Liquid line_item.key no longer matches the key returned by cart/change.js.

Additional info

When building a mini cart that uses line_item.key to identify each line item and send quantity update requests to /cart/change.js, everything works perfectly under normal conditions. However, as soon as an automatic discount scoped at the cart discount level (not at the line item level) is applied, the line_item.key returned in the JS response no longer matches the one exposed in Liquid.

Furthermore, the key itself changes every time the quantity is updated, making it impossible to reliably track line items across successive cart operations.

As a concrete example, in the Impact theme, this mismatch causes a visual glitch: the line item disappears and reappears with the updated quantity, whereas without a discount, the quantity update renders with a smooth animation.

What type of topic is this

Bug report

Upload screenshot(s) of issue

Line item key without automatic discount
Line item key with automatic discount