mutation cartLinesAdd return specified cart does not exist

Have an app based on 2024-04 API version which successfully add products to cart via GraphQL.

After few weeks customers who has app working started report the sudden fail of the add to cart function. There were no code changes from our side.

So mutation cartLinesAdd in graphQL starts to return errors like specified cart does not exist

Looks like Shopify update something in the background instead of pushing new changes to new version(!?) of API for example https://shopify.dev/changelog/storefront-api-changes-when-cart-id-is-missing-the-key-param

Anyway my dev store works just fine but

client 1: does not have any key when Carts_Update webhook received so cart add action is fail (why it works before..)

GraphQL cart ADD Full response: {"data"=>{"cartLinesAdd"=>{"cart"=>{"id"=>"gid://shopify/Cart/Z2NwLWV1cm9wZS13ZXN0MTowMUo2RjlNVEJIUkhUN1pUWU5CWFkyVXXX", "lines"=>{"edges"=>[{"node"=>{"id"=>"gid://shopify/CartLine/9deb7f57-72d1-4c34-87e5-3267b437b9ea?cart=Z2NwLWV1cm9wZS13ZXN0MTowMUo2RjlNVEJIUkhUN1pUWU5CWFkyXXX", "quantity"=>1, "merchandise"=>{"id"=>"gid://shopify/ProductVariant/45375246237834", "priceV2"=>{"amount"=>"35.0", "currencyCode"=>"USD"}}}}]}}, "userErrors"=>[{"field"=>["cartId"], "message"=>"The specified cart does not exist."}]}}}, Shopify Domain: store1.myshopify.com

client 2: does have a key in param but starts to receive same specified cart does not exist

GraphQL cart ADD Full response: {"data"=>{"cartLinesAdd"=>{"cart"=>{"id"=>"gid://shopify/Cart/Z2NwLWV1cm9wZS13ZXN0MTowMUo2RVpITkFOWFIzUU5aSkg0SzZNSlhZMA?key=bc0a4d08e11fa3cdcd234c96c092d6XX", "lines"=>{"edges"=>[{"node"=>{"id"=>"gid://shopify/CartLine/84cae575-3485-4e62-ad95-a54f05fc2655?cart=Z2NwLWV1cm9wZS13ZXN0MTowMUo2RVpITkFOWFIzUU5aSkg0SzZNSlhZMA", "quantity"=>1, "merchandise"=>{"id"=>"gid://shopify/ProductVariant/45375246237834", "priceV2"=>{"amount"=>"35.0", "currencyCode"=>"GBP"}}}}]}}, "userErrors"=>[{"field"=>["cartId"], "message"=>"The specified cart does not exist."}]}}}, Shopify Domain: somestore2.myshopify.com

Before adding the cart I do call GraphQL like in hope to receive the cart id with key

query GetCartFromId($cartId: ID!) {
        cart(id: $cartId) {

but for the store1 the returned value does not have a key, for second store it has but anyway adding product to cart is stop working.

Note: all works just fine for a weeks and no changes from app code or server.

Note2: all works fine on my dev store.

Would be nice to have some help before telling clients to migrate

1 Like

I’m facing with the same issue. I’m not sure whether it related to this topic or not https://shopify.dev/changelog/storefront-api-changes-when-cart-id-is-missing-the-key-param

1 Like

@lokki54 I tried with api https://shopify.dev/docs/api/storefront/2024-04/mutations/cartAttributesUpdate. it’s working well. Have we face with error only for cartLinesAdd or cartLinesUpdate?

Did you add products with the /cartAttributesUpdate? Let me know please how or full example of the request.

I use the https://shopify.dev/docs/api/storefront/2024-04/mutations/cartLinesAdd

mutation cartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {
          cartLinesAdd(cartId: $cartId, lines: $lines) {

this is my request without key param on cartId:

mutation cartAttributesUpdate($attributes: [AttributeInput!]!, $cartId: ID!) {
    cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {
      cart {
        # Cart fields
        note
        totalQuantity
        checkoutUrl
        attributes{
          key
          value
        }
      }
      userErrors {
        field
        message
      }
    }
  }

{
    "cartId": "gid://shopify/Cart/Z2NwLWFzaWEtc291dGhlYXN0MTowMUo2UlpBRk00U0E2WUdDTVI1NzRTSjNHUA",
    "attributes": [{
        "key":"ab3c",
        "value": "mason"
    }]
}

thank you for the example however my app does not work with attributes but adds and removes products to the cart based on certain conditions and looks like recent Shopify changes ruined all for some of my customers… they starting to remove the app and cancel subscriptions.

Interestingly it still work on my developer shop so still have no idea why shopify is different for them

1 Like

@lokki54 mee too. The issue only happening with some client’s stores, Not sure why

1 Like

@lokki54 I’m having the same issue in my custom app, which uses cartDiscountCodesUpdate API, which failed because “The specified cart does not exist”. I queried the same Cart ID using the GraphiQL App, which works fine. No Idea what’s happening! My custom app worked fine last month.

cart query

{
  cart(id: "gid://shopify/Cart/Z2NwLXVzLWNlbnRyYWwxOjAxSjhGUllKTjZSRzc5WjBQNktFMFNLTktY") {
    checkoutUrl
    discountCodes {
      code
    }
    id
    lines(first: 250) {
      nodes {
        quantity
        id
      }
    }
  }
}

cartDiscountCodesUpdate mutation

mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {
    cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
      cart {
        cost {
          checkoutChargeAmount {
            amount
          }
        }
      }
      userErrors {
        code
        message
        field
      }
    }
  }

1 Like

What’s happening is that Shopify deployed new changes (or bug) without prior notice, which has disrupted all apps relying on those features. Now, this has impacted all of my clients…

1 Like

It’s incredibly disappointing when unexpected changes disrupt our work, especially when we’re trying to deliver a custom app to a client. It’s tough to face those situations where we feel like we’ve let our clients down due to factors beyond our control. As developers, we rely on consistent features to ensure our apps run smoothly, and sudden changes can throw a wrench in our plans. I’m considering shifting my focus away from Shopify projects, it might be worth exploring other platforms or even sticking to theme development for now.

1 Like