magento2: After upgrading to new version - No such entity with customerId critical logs
Summary
Sorry to say this, but as usually, after upgrading Magento versions something is wrong at the end.
I did have no exceptions and no errors before.
Now upgrading to 2.3.2 I get exceptions like:
[2019-06-25 21:46:34] main.CRITICAL: Keine Eintrag mit customerId = 1 {"exception":"[object] (Magento\\Framework\\Exception\\NoSuchEntityException(code: 0): Keine Eintrag mit customerId = 1 at /var/www/vhosts/hopfenmuseum-tettnang.de/magento.hopfenexpress.de/vendor/magento/framework/Exception/NoSuchEntityException.php:50)"} []
Preconditions
Magento 2.3.2 PHP 7.2
Steps to reproduce
- Setup vanilla Magento 2.3.2 using composer (no sample data is needed)
- In the backend, create a category and a product
- In the frontend, register as a new customer
- Put the product in your cart and go to the checkout 5 .Enter your shipping address and use the same address in the payment step
- Place an order
- Look at the var/log/exception.log file, it contains 4 errors:
[2019-06-29 14:34:05] main.CRITICAL: No such entity with customerId = 1 {"exception":"[object] (Magento\\Framework\\Exception\\NoSuchEntityException(code: 0): No such entity with customerId = 1 at vendor/magento/framework/Exception/NoSuchEntityException.php:50)"} []
[2019-06-29 14:34:06] main.CRITICAL: No such entity with customerId = 1 {"exception":"[object] (Magento\\Framework\\Exception\\NoSuchEntityException(code: 0): No such entity with customerId = 1 at vendor/magento/framework/Exception/NoSuchEntityException.php:50)"} []
[2019-06-29 14:34:08] main.CRITICAL: No such entity with customerId = 1 {"exception":"[object] (Magento\\Framework\\Exception\\NoSuchEntityException(code: 0): No such entity with customerId = 1 at vendor/magento/framework/Exception/NoSuchEntityException.php:50)"} []
[2019-06-29 14:34:08] main.CRITICAL: No such entity with customerId = 1 {"exception":"[object] (Magento\\Framework\\Exception\\NoSuchEntityException(code: 0): No such entity with customerId = 1 at vendor/magento/framework/Exception/NoSuchEntityException.php:50)"} []
- Go to the home page or any other page while still being logged in
- An additional line is added to the
var/log/exception.logfile each time you visit a page:
[2019-06-29 14:36:58] main.CRITICAL: No such entity with customerId = 1 {"exception":"[object] (Magento\\Framework\\Exception\\NoSuchEntityException(code: 0): No such entity with customerId = 1 at vendor/magento/framework/Exception/NoSuchEntityException.php:50)"} []
Expected result
No errors
Actual result
[2019-06-29 14:34:05] main.CRITICAL: No such entity with customerId = 1 {“exception”:“[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): No such entity with customerId = 1 at vendor/magento/framework/Exception/NoSuchEntityException.php:50)”} [] [2019-06-29 14:34:06] main.CRITICAL: No such entity with customerId = 1 {“exception”:“[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): No such entity with customerId = 1 at vendor/magento/framework/Exception/NoSuchEntityException.php:50)”} [] [2019-06-29 14:34:08] main.CRITICAL: No such entity with customerId = 1 {“exception”:“[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): No such entity with customerId = 1 at vendor/magento/framework/Exception/NoSuchEntityException.php:50)”} [] [2019-06-29 14:34:08] main.CRITICAL: No such entity with customerId = 1 {“exception”:“[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): No such entity with customerId = 1 at vendor/magento/framework/Exception/NoSuchEntityException.php:50)”} []
Additional information
From the comment
This last one seems to come from the ajax request to /customer/section/load/?sections=cart&force_new_section_timestamp=false&_=1561818997600
Putting a break point in that NoSuchEntityException.php file on line 50 and then calling that ajax endpoint, gives me the following stack trace:
Magento\Framework\Exception\NoSuchEntityException::singleField (vendor/magento/framework/Exception/NoSuchEntityException.php:50)
Magento\Quote\Model\QuoteRepository\Interceptor->loadQuote (vendor/magento/module-quote/Model/QuoteRepository.php:232)
Magento\Quote\Model\QuoteRepository\Interceptor->getForCustomer (vendor/magento/module-quote/Model/QuoteRepository.php:149)
Magento\Quote\Model\QuoteRepository\Interceptor->___callParent (vendor/magento/framework/Interception/Interceptor.php:58)
Magento\Quote\Model\QuoteRepository\Interceptor->Magento\Framework\Interception\{closure:vendor/magento/framework/Interception/Interceptor.php:104-151} (vendor/magento/framework/Interception/Interceptor.php:138)
Magento\Quote\Model\QuoteRepository\Interceptor->___callPlugins (vendor/magento/framework/Interception/Interceptor.php:153)
Magento\Quote\Model\QuoteRepository\Interceptor->getForCustomer (generated/code/Magento/Quote/Model/QuoteRepository/Interceptor.php:39)
Magento\Quote\Model\QuoteRepository\Interceptor->getActiveForCustomer (vendor/magento/module-quote/Model/QuoteRepository.php:174)
Magento\Quote\Model\QuoteRepository\Interceptor->___callParent (vendor/magento/framework/Interception/Interceptor.php:58)
Magento\Quote\Model\QuoteRepository\Interceptor->Magento\Framework\Interception\{closure:vendor/magento/framework/Interception/Interceptor.php:104-151} (vendor/magento/framework/Interception/Interceptor.php:138)
Magento\Quote\Model\QuoteRepository\Interceptor->___callPlugins (vendor/magento/framework/Interception/Interceptor.php:153)
Magento\Quote\Model\QuoteRepository\Interceptor->getActiveForCustomer (generated/code/Magento/Quote/Model/QuoteRepository/Interceptor.php:65)
Magento\Checkout\Model\Session\Interceptor->getQuote (vendor/magento/module-checkout/Model/Session.php:274)
Magento\Checkout\Model\Session\Interceptor->getQuote (generated/code/Magento/Checkout/Model/Session/Interceptor.php:63)
Magento\Checkout\CustomerData\Cart\Interceptor->getQuote (vendor/magento/module-checkout/CustomerData/Cart.php:116)
Magento\Checkout\CustomerData\Cart\Interceptor->getSectionData (vendor/magento/module-checkout/CustomerData/Cart.php:91)
Magento\Checkout\CustomerData\Cart\Interceptor->___callParent (vendor/magento/framework/Interception/Interceptor.php:58)
Magento\Checkout\CustomerData\Cart\Interceptor->Magento\Framework\Interception\{closure:vendor/magento/framework/Interception/Interceptor.php:104-151} (vendor/magento/framework/Interception/Interceptor.php:138)
Magento\Checkout\CustomerData\Cart\Interceptor->___callPlugins (vendor/magento/framework/Interception/Interceptor.php:153)
Magento\Checkout\CustomerData\Cart\Interceptor->getSectionData (generated/code/Magento/Checkout/CustomerData/Cart/Interceptor.php:26)
Magento\Customer\CustomerData\SectionPool->getSectionDataByNames (vendor/magento/module-customer/CustomerData/SectionPool.php:79)
Magento\Customer\CustomerData\SectionPool->getSectionsData (vendor/magento/module-customer/CustomerData/SectionPool.php:60)
Magento\Customer\Controller\Section\Load\Interceptor->execute (vendor/magento/module-customer/Controller/Section/Load.php:78)
Magento\Customer\Controller\Section\Load\Interceptor->execute (generated/code/Magento/Customer/Controller/Section/Load/Interceptor.php:24)
Magento\Customer\Controller\Section\Load\Interceptor->dispatch (vendor/magento/framework/App/Action/Action.php:108)
Magento\Customer\Controller\Section\Load\Interceptor->___callParent (vendor/magento/framework/Interception/Interceptor.php:58)
Magento\Customer\Controller\Section\Load\Interceptor->Magento\Framework\Interception\{closure:vendor/magento/framework/Interception/Interceptor.php:104-151} (vendor/magento/framework/Interception/Interceptor.php:138)
Magento\Customer\Controller\Section\Load\Interceptor->___callPlugins (vendor/magento/framework/Interception/Interceptor.php:153)
Magento\Customer\Controller\Section\Load\Interceptor->dispatch (generated/code/Magento/Customer/Controller/Section/Load/Interceptor.php:39)
Magento\Framework\App\FrontController\Interceptor->processRequest (vendor/magento/framework/App/FrontController.php:159)
Magento\Framework\App\FrontController\Interceptor->dispatch (vendor/magento/framework/App/FrontController.php:99)
Magento\Framework\App\FrontController\Interceptor->___callParent (vendor/magento/framework/Interception/Interceptor.php:58)
Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure:vendor/magento/framework/Interception/Interceptor.php:104-151} (vendor/magento/framework/Interception/Interceptor.php:138)
Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch (vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:94)
Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure:vendor/magento/framework/Interception/Interceptor.php:104-151} (vendor/magento/framework/Interception/Interceptor.php:135)
Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch (vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:73)
Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure:vendor/magento/framework/Interception/Interceptor.php:104-151} (vendor/magento/framework/Interception/Interceptor.php:135)
Magento\Framework\App\FrontController\Interceptor->___callPlugins (vendor/magento/framework/Interception/Interceptor.php:153)
Magento\Framework\App\FrontController\Interceptor->dispatch (generated/code/Magento/Framework/App/FrontController/Interceptor.php:26)
Magento\Framework\App\Http\Interceptor->launch (vendor/magento/framework/App/Http.php:137)
Magento\Framework\App\Http\Interceptor->launch (generated/code/Magento/Framework/App/Http/Interceptor.php:24)
Magento\Framework\App\Bootstrap->run (vendor/magento/framework/App/Bootstrap.php:261)
{main} (pub/index.php:40)
I’m not sure how important this problem is and what is breaks exactly. But it doesn’t sound very good…
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 20
- Comments: 60 (19 by maintainers)
Commits related to this issue
- Remove misplaced critical log There is no longer a critical error when a logged in customer has no active quote - which is e.g. the case when an order was placed but no new quote was yet created. @s... — committed to david-fuehr/magento2 by david-fuehr 5 years ago
- Remove misplaced critical log There is no longer a critical error when a logged in customer has no active quote - which is e.g. the case when an order was placed but no new quote was yet created. @s... — committed to hostep/magento2 by david-fuehr 5 years ago
The commit https://github.com/magento/magento2/commit/117d7103de2989168af45de550091e79f815d54e improved quote (error) handling but also introduced a log that is wrong in my opinion. It was first delivered with 2.3.2.
Line 276 from that commit logs a critical error, when a
\Magento\Framework\Exception\NoSuchEntityExceptionoccurs. Inspecting the context of that line, this should not be done:\Magento\Checkout\Model\Session.php:268-283The whole method could use some (or some more) refactoring, but this block should get the last active quote for a customer. Especially after placing an order and before adding products to a new quote, there is never an active quote for a customer. Therefore (with the least impact to the method) the line 277
$this->logger->critical($e);should be dropped.I will prepare a pull request for this.
Additional information: the critical log is actually a false positive - nothing is wrong except the log entry itself.
Still appearing on on 2.3.4 - jesus - nothing but bugs.
@chequille: thanks for the effort to keep testing this problem! I was able to very easily reproduce the problem based on your comments:
var/log/exception.logfile, it contains 4 errors:var/log/exception.logfile each time you visit a page:This last one seems to come from the ajax request to
/customer/section/load/?sections=cart&force_new_section_timestamp=false&_=1561818997600Putting a break point in that
NoSuchEntityException.phpfile on line 50 and then calling that ajax endpoint, gives me the following stack trace:I’m not sure how important this problem is and what is breaks exactly. But it doesn’t sound very good…
@engcom-Charlie: can you also test this again?
Still happening in Magento 2.3.3.
Everybody is facing this problem, because it is a core bug !!! Sorry to the Magento team, but I really cannot understand this. Updates should fix bugs and security stuff, but not introduce new bugs. I like the system anyway, but sometimes it is really strange what happens.
Nevertheless, do your best to fix this soon. I am waiting !! BR Chequille
Hi everyone, I’ve got the same error: The order is complete but no confirmation email was sent
Is this issue still on the radar of the Magento developers? Because the PR of @david-fuehr was closed due to inactivity… and it’s very annoying to have the exception log flooded with this message. Makes it inconvenient to find real exceptions.
It seems to be fixed in 2.3.5 I do not have the error anymore.
I updated function getQuoteByCustomer and it work better.
@jsdupuis you can use this as patch file: https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/25307.diff
Please make sure you make the paths correct when you use a composer installation.
We are getting “No such entity with quote_id” when we are trying to place an order and not able to place the order at all. Magento version is 2.3.5-p1. I have checked “vendor/magento/module-checkout/Model/Session.php” and looks like the patch is already implemented in that file but still we are getting error.
@textarea: could you open a new issue and please try to list steps to reproduce so it can be followed up properly.
Thanks! 🙂
Having the same issue on 2.3.3 when placing an order. (order placed successfully. but confirmation email is not going)
Hello @j-lloyd-slc @sumitvgupta @samumaretiya
As I can see this issue should be fixed not in the
2.3-developthe PR with the fix was proposed by @hostep and delivered in https://github.com/magento/magento2/pull/25307Could you please confirm that https://github.com/magento/magento2/pull/25307 fixed the issue and we can close it? or we still have some cases/scenarios that not fixed