Webhook carts/update missing cart key

the carts/update webhook starts send the cartID without the recently started to be required key . example of the received data

"ShopifyApp"::"WebhooksController#receive as */*
  Parameters":{
   "id""=>""Z2NwLWV1cm9wZS13ZXN0MTowMUo2U0U4RDVDUUNYQ0RHN0NFMTdaQVlGMA",
   "token""=>""[FILTERED]",
   "line_items""=>"[
      {
         "id"=>39385543344183,
         "properties""=>nil",
         "quantity"=>2,
         "variant_id"=>39385543344183,
         "key""=>""39385543344183:f2b96a3f13539566d870d3dbccde355e",
         "discounted_price""=>""74.00",
         "discounts""=>"[
            
         ],
         "gift_card""=>false",
         "grams"=>356,
         "line_price""=>""148.00",
         "original_line_price""=>""148.00",
         "original_price""=>""74.00",
         "price""=>""74.00",
         "product_id"=>6573328171063,
         "sku""=>""",
         "taxable""=>true",
         "title""=>""LED High Tops - US 8",
         "total_discount""=>""0.00",
         "vendor""=>""Liam Fashions",
         "discounted_price_set""=>"{
            "shop_money""=>"{
               "amount""=>""74.0",
               "currency_code""=>""EUR"
            },
            "presentment_money""=>"{
               "amount""=>""74.0",
               "currency_code""=>""EUR"
            }
         },
         "line_price_set""=>"{
            "shop_money""=>"{
               "amount""=>""148.0",
               "currency_code""=>""EUR"
            },
            "presentment_money""=>"{
               "amount""=>""148.0",
               "currency_code""=>""EUR"
            }
         },
         "original_line_price_set""=>"{
            "shop_money""=>"{
               "amount""=>""148.0",
               "currency_code""=>""EUR"
            },
            "presentment_money""=>"{
               "amount""=>""148.0",
               "currency_code""=>""EUR"
            }
         },
         "price_set""=>"{
            "shop_money""=>"{
               "amount""=>""74.0",
               "currency_code""=>""EUR"
            },
            "presentment_money""=>"{
               "amount""=>""74.0",
               "currency_code""=>""EUR"
            }
         },
         "total_discount_set""=>"{
            "shop_money""=>"{
               "amount""=>""0.0",
               "currency_code""=>""EUR"
            },
            "presentment_money""=>"{
               "amount""=>""0.0",
               "currency_code""=>""EUR"
            }
         }
      }
   ],
   "note""=>""",
   "updated_at""=>""2024-09-02T13:23:17.863Z",
   "created_at""=>""2024-09-02T13:19:46.210Z",
   "type""=>""carts_update",
   "webhook""=>"{
      "id""=>""Z2NwLWV1cm9wZS13ZXN0MTowMUo2U0U4RDVDUUNYQ0RHN0NFMTdaQVlGMA",
      "token""=>""[FILTERED]",
      "line_items""=>"[
         {
            "id"=>39385543344183,
            "properties""=>nil",
            "quantity"=>2,
            "variant_id"=>39385543344183,
            "key""=>""39385543344183:f2b96a3f13539566d870d3dbccde355e",
            "discounted_price""=>""74.00",
            "discounts""=>"[
               
            ],
            "gift_card""=>false",
            "grams"=>356,
            "line_price""=>""148.00",
            "original_line_price""=>""148.00",
            "original_price""=>""74.00",
            "price""=>""74.00",
            "product_id"=>6573328171063,
            "sku""=>""",
            "taxable""=>true",
            "title""=>""LED High Tops - US 8",
            "total_discount""=>""0.00",
            "vendor""=>""Liam Fashions",
            "discounted_price_set""=>"{
               "shop_money""=>"{
                  "amount""=>""74.0",
                  "currency_code""=>""EUR"
               },
               "presentment_money""=>"{
                  "amount""=>""74.0",
                  "currency_code""=>""EUR"
               }
            },
            "line_price_set""=>"{
               "shop_money""=>"{
                  "amount""=>""148.0",
                  "currency_code""=>""EUR"
               },
               "presentment_money""=>"{
                  "amount""=>""148.0",
                  "currency_code""=>""EUR"
               }
            },
            "original_line_price_set""=>"{
               "shop_money""=>"{
                  "amount""=>""148.0",
                  "currency_code""=>""EUR"
               },
               "presentment_money""=>"{
                  "amount""=>""148.0",
                  "currency_code""=>""EUR"
               }
            },
            "price_set""=>"{
               "shop_money""=>"{
                  "amount""=>""74.0",
                  "currency_code""=>""EUR"
               },
               "presentment_money""=>"{
                  "amount""=>""74.0",
                  "currency_code""=>""EUR"
               }
            },
            "total_discount_set""=>"{
               "shop_money""=>"{
                  "amount""=>""0.0",
                  "currency_code""=>""EUR"
               },
               "presentment_money""=>"{
                  "amount""=>""0.0",
                  "currency_code""=>""EUR"
               }
            }
         }
      ],
      "note""=>""",
      "updated_at""=>""2024-09-02T13:23:17.863Z",
      "created_at""=>""2024-09-02T13:19:46.210Z"
   }
}

in the example above the id is the actual CartID but with missing ?key param so when we use it in the application (GraphQL 2024-07) the API responce is Cart id does not exist.

1 Like

Hi,

I’ve connected with the product team on this and they’ve tested to confirm it’s a bug on our side. We’re exploring how to fix this but for now I don’t have an ETA to share on when this will be resolved. I’ll update here when I learn more.

2 Likes

Thank you for looking into this. I have confirmation from other app developers who is affected so many app rely on this.

I wanted to check in and see if there’s any news or an estimated timeline for when the fix might be available. Please let me know if there’s anything I can assist with on my end to help move things forward.

Thank you for your time

Hi, ran into this as well, would appreciate an update. Thanks

1 Like

@Liam-Shopify is there any update? It should be a simple fix.

1 Like

@Liam-Shopify ran into this issue on my end as well - bumping to see if there is any update.

For reference this change rolled out on August 15, 2024 so its been over 3 months now. Just hoping we can get this escalated.

1 Like

@Liam-Shopify Please provide an ETA

heeeeeyyyy ))) anyone please fix the bug :grimacing:

Hey folks - will re-connect with the relevant team on this, appreciate your patience!

1 Like

Hey folks - if you’re still affected by this issue, please let me know here and I’ll DM you to have a fix applied to stores.

@Liam-Shopify we’re still affected by this issue, the query cart - Storefront API is also returning an ID without a Key

1 Like

I’m experiencing the same issue; unfortunately, it’s far from being resolved. I just tested the cart_update webhook on the dev store. The Cart received without required param

ShopifyApp"::"WebhooksController#receive as */*
  Parameters":{
   "id""=>""Z2NwLWV1cm9wZS13ZXN0MTowMUpNSEhBOTNXMTM2QUs5NFhYMUpaWjZKUw",
   "token""=>""[FILTERED]",
   "line_items""=>"[

should be like "id""=>""Z2NwLWV1cm9wZS13ZXN0MTowMUpNSEhBOTNXMTM2QUs5NFhYMUpaWjZKUw?key= 824bdj25mhg1242bdb385"

Thanks - have DMed you both

Heya–I’m having the same issue. Any resolution or ETA?

This workaround code works for me in a liquid code script:

<script>
document.addEventListener("DOMContentLoaded", function () {
    fetch('/cart.js')
        .then(response => response.json())
        .then(data => {
            let cartId = data.token; // ✅ Get cart ID

            // If cartId does NOT contain "?key=", create a new cart
            if (!cartId.includes("?key=")) {
                console.warn("Cart ID is missing ?key=, creating new cart...");

                fetch("/cart/update.js", {
                    method: "POST",
                    headers: { "Content-Type": "application/json" },
                    body: JSON.stringify({}) // Empty body to initialize cart
                })
                .then(() => fetch('/cart.js')) // Fetch updated cart
                .then(response => response.json())
                .then(newData => {
                    cartId = newData.token;
                    doSomething(cartId);
                })
                .catch(error => console.error("Error creating cart:", error));
            } else {
                doSomething(cartId);
            }
        })
        .catch(error => console.error("Error fetching cart ID:", error));
});
function doSomething(cartId) {
 console.log("Working Cart ID is: ", cartId);
}

</script>