magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.31k forks source link

No Such Entity With Cart ID #5847

Closed saderra closed 6 years ago

saderra commented 8 years ago

Preconditions

  1. Magento 2.1, upgraded from 2.0.7 Droplet on Digital Ocean

    Steps to reproduce

  1. Add products to cart
  2. Proceed to checkout, using Authorize.net DPM (Verified Settings)
  3. Click Checkout

    Expected result

  1. Transaction processes, order is created

    Actual result

  1. The card is charged, and the response comes back from authorize.net. The charge is verified. However, the error "no such entity with cartid = X" is displayed, and the checkout page remains dimmed with JS spinner.
JelleGe commented 3 years ago

Hope this will help.

Thanks, but how did you solve this issue?

shuffless commented 3 years ago

Thanks, but how did you solve this issue?

I disabled the plugin that was setting a SMTP gateway (I used something for Amazon SES), then ran update, cleared cache and recompiled.

Once that was ready I did set the native Magento email sending option (https://docs.magento.com/user-guide/system/email-communications.html).

cjohansson commented 1 year ago

Same issue here with a Magento ver. 2.4.4, I don't understand why this issue is closed

stratus21-liam commented 1 year ago

@cjohansson me too, did you fix it? I have a live site and staging site. Live was on 2.3.6 having this issue so I upgraded staging to 2.4.4-p2 and still having the same issue. My problem is that it happens with OneStepcheckout and if I disable that module and use the core checkout it works fine.. yet this checkout is used on all my sites with no issues

cjohansson commented 1 year ago

@wkdcode-liam I have not found a fix for it, the error messages says a cart with a specific ID does not exist even though it exists in the database. In another 2.4.4 I don't encounter this error, I am not sure why. It is possible that the issue is not what it says it is, the error message might be missleading

cjohansson commented 1 year ago

For example, the error message says No such entity with cartId = 34080 but if I run SQL query

SELECT * FROM quote WHERE entity_id = 3408

I actually find a quote

cjohansson commented 1 year ago

Ok I solved the issue now, the issue is not what Magento 2 reports, check the XHR log in checkout for other potential issues, in my case a e-mail module failed to send e-mail and that showed the error

rossparachute commented 1 year ago

Still seeing this on v2.4.5-p1 using the official Stripe module (stripe/stripe-payments) v3.3 running on PHP 8.1.13.

"No such entity with cartId = "

It seems to happen intermittently. We've looked at this for a fair while and it isn't clear exactly why the session appears to be lost (working theory) but it's too often to chalk up to the cart just expiring.

This is in a multi-store setup (two stores).

Example stacktrace:

[2023-02-06T10:58:09.926011+00:00] main.CRITICAL: Magento\Framework\Exception\NoSuchEntityException: No such entity with cartId =  in /vendor/magento/framework/Exception/NoSuchEntityException.php:50
Stack trace:
#0 vendor/magento/module-quote/Model/QuoteRepository.php(238): Magento\Framework\Exception\NoSuchEntityException::singleField()
#1 vendor/magento/module-quote/Model/QuoteRepository.php(136): Magento\Quote\Model\QuoteRepository->loadQuote()
#2 vendor/magento/framework/Interception/Interceptor.php(58): Magento\Quote\Model\QuoteRepository->get()
#3 vendor/magento/framework/Interception/Interceptor.php(138): Magento\Quote\Model\QuoteRepository\Interceptor->___callParent()
#4 vendor/magento/framework/Interception/Interceptor.php(153): Magento\Quote\Model\QuoteRepository\Interceptor->Magento\Framework\Interception\{closure}()
#5 generated/code/Magento/Quote/Model/QuoteRepository/Interceptor.php(23): Magento\Quote\Model\QuoteRepository\Interceptor->___callPlugins()
#6 vendor/magento/module-quote/Model/QuoteRepository.php(168): Magento\Quote\Model\QuoteRepository\Interceptor->get()
#7 generated/code/Magento/Quote/Model/QuoteRepository/Interceptor.php(32): Magento\Quote\Model\QuoteRepository->getActive()
#8 vendor/magento/module-gift-message/Model/CartRepository.php(81): Magento\Quote\Model\QuoteRepository\Interceptor->getActive()
#9 vendor/magento/module-gift-message/Model/GiftMessageConfigProvider.php(172): Magento\GiftMessage\Model\CartRepository->get()
#10/vendor/magento/module-gift-message/Model/GiftMessageConfigProvider.php(113): Magento\GiftMessage\Model\GiftMessageConfigProvider->getOrderLevelGiftMessages()
#11/vendor/magento/module-gift-message/Model/CompositeConfigProvider.php(36): Magento\GiftMessage\Model\GiftMessageConfigProvider->getConfig()
#12/vendor/magento/module-gift-message/Block/Cart/GiftOptions.php(88): Magento\GiftMessage\Model\CompositeConfigProvider->getConfig()
#13/vendor/magento/module-gift-message/view/frontend/templates/cart/gift_options.phtml(21): Magento\GiftMessage\Block\Cart\GiftOptions->getGiftOptionsConfigJson()
#14/vendor/magento/framework/View/TemplateEngine/Php.php(71): include()
#15/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\TemplateEngine\Php->render()
#16/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\TemplateEngine\Php\Interceptor->___callParent()
#17/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\TemplateEngine\Php\Interceptor->Magento\Framework\Interception\{closure}()
#18/generated/code/Magento/Framework/View/TemplateEngine/Php/Interceptor.php(23): Magento\Framework\View\TemplateEngine\Php\Interceptor->___callPlugins()
#19/vendor/magento/framework/View/Element/Template.php(263): Magento\Framework\View\TemplateEngine\Php\Interceptor->render()
#20/vendor/magento/framework/View/Element/Template.php(293): Magento\Framework\View\Element\Template->fetchView()
#21/vendor/magento/module-backend/Block/Template.php(141): Magento\Framework\View\Element\Template->_toHtml()
#22/vendor/magento/framework/View/Element/AbstractBlock.php(1095): Magento\Backend\Block\Template->_toHtml()
#23/vendor/magento/framework/View/Element/AbstractBlock.php(1099): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}()
#24/vendor/magento/framework/View/Element/AbstractBlock.php(660): Magento\Framework\View\Element\AbstractBlock->_loadCache()
#25/vendor/magento/framework/View/Layout.php(578): Magento\Framework\View\Element\AbstractBlock->toHtml()
#26/vendor/magento/framework/View/Layout.php(555): Magento\Framework\View\Layout->_renderBlock()
#27/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement()
#28/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement()
#29/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement()
#30/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement()
#31/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#32/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement()
#33/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement()
#34/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement()
#35/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement()
#36/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#37/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement()
#38/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement()
#39/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement()
#40/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement()
#41/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#42/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement()
#43/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement()
#44/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement()
#45/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement()
#46/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#47/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement()
#48/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement()
#49/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement()
#50/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement()
#51/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#52/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement()
#53/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement()
#54/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement()
#55/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement()
#56/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#57/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement()
#58/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement()
#59/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement()
#60/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement()
#61/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#62/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement()
#63/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement()
#64/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement()
#65/vendor/magento/framework/View/Layout.php(975): Magento\Framework\View\Layout\Interceptor->renderElement()
#66/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Layout->getOutput()
#67/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Layout\Interceptor->___callParent()
#68/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}()
#69/generated/code/Magento/Framework/View/Layout/Interceptor.php(347): Magento\Framework\View\Layout\Interceptor->___callPlugins()
#70/vendor/magento/framework/View/Result/Page.php(260): Magento\Framework\View\Layout\Interceptor->getOutput()
#71/vendor/magento/framework/View/Result/Layout.php(171): Magento\Framework\View\Result\Page->render()
#72/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Result\Layout->renderResult()
#73/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor->___callParent()
#74/app/code/Magezon/Core/Plugin/View/Result/Layout.php(24): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}()
#75/vendor/magento/framework/Interception/Interceptor.php(135): Magezon\Core\Plugin\View\Result\Layout->aroundRenderResult()
#76/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}()
#77/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(32): Magento\Framework\View\Result\Page\Interceptor->___callPlugins()
#78/vendor/magento/framework/App/Http.php(120): Magento\Framework\View\Result\Page\Interceptor->renderResult()
#79/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http->launch()
#80/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
#81/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#82 {main} [] []
Raffail commented 1 year ago

I encountered this issue today after copying a live site to dev environment. Just cleaned a browser cookies for dev site, and everything works fine.

rossparachute commented 1 year ago

@Raffail

Think I might have found it, we wanted to slightly tweak the behaviour of shipping information and gift messaging. So we copied the original method and tweaked the small bit we needed to.

There isn't a null or empty check in the stuff we copied or a try/catch that handles a NoSuchEntityException.

The two lines that threw the error are straight from Magento but in fairness, I should have handled that condition even if the Magento stuff didn't. May well be good reason why they'd want it to fail if no cart id was passed. The logs not showing specifically which interceptor didn't help though.

There's probably a few places where the "No such entity with cart ID = ''" will get thrown.

Like you say, I've seen it happen as well in Magento_Customer etc. when the session id is out of date too.

https://github.com/magento/magento2/blob/d48a739e3503728168e4fe005e8663389a935659/app/code/Magento/Checkout/Model/ShippingInformationManagement.php#L163

    public function saveAddressInformation(
        $cartId,
        ShippingInformationInterface $addressInformation
    ): PaymentDetailsInterface {
        /** @var Quote $quote */
        $quote = $this->quoteRepository->getActive($cartId); <!--- Might be empty
        ...
   }

https://github.com/magento/magento2/blob/d48a739e3503728168e4fe005e8663389a935659/app/code/Magento/GiftMessage/Model/CartRepository.php#L101

    public function save($cartId, \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage)
    {
        /**
         * Quote.
         *
         * @var \Magento\Quote\Model\Quote $quote
         */
        $quote = $this->quoteRepository->getActive($cartId); <!-- Might be empty
        ...
    }
stratus21-liam commented 1 year ago

We gave up with ours mate, ditched the checkout and put another one on which worked fine.

​Liam Chowney Magento Developer @.*** | www.stratus21.com

​Stratus21 Ltd is a private limited company registered in England. Registered number: 0089780. ​Registered office: Millers House, Roman Way, Market Harborough, United Kingdom, LE16 7PQ.

​Disclaimer: This email and its attachments may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of Stratus21 Ltd, or any of its subsidiaries. If you are not the intended recipient of this email and its attachments, you must take no action based upon them, nor must you copy or show them to anyone. Please contact the sender if you believe you have received this email in error. ​


From: Christian Johansson @.> Sent: 08 November 2022 16:39 To: magento/magento2 @.> Cc: Liam Chowney @.>; Mention @.> Subject: Re: [magento/magento2] No Such Entity With Cart ID (#5847)

@wkdcode-liamhttps://github.com/wkdcode-liam I have not found a fix for it, the error messages says a cart with a specific ID does not exist even though it exists in the database. In another 2.4.4 I don't encounter this error, I am not sure why. It is possible that the issue is not what it says it is, the error message might be missleading

— Reply to this email directly, view it on GitHubhttps://github.com/magento/magento2/issues/5847#issuecomment-1307505114, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANEKJIK72UBLAQOYYO6AN3LWHJ62LANCNFSM4CK3BZVA. You are receiving this because you were mentioned.Message ID: @.***>