Magento2: No such entity with addressId, occurs randomly on visitors browser. System Log Generated

Created on 9 May 2018  Â·  57Comments  Â·  Source: magento/magento2

We've been having an issue on our 2.2.3 installation in Production. On occasion a visitor will report they have this System Log Generated error show up instead of the web page. I've managed to get it myself just a couple times. Every single time when you go to the filesystem and check the report it reports the following:

{"0":"No such entity with addressId = 45879","1":"#0 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/module-customer\/Model\/AddressRegistry.php(49): Magento\Framework\Exception\NoSuchEntityException::singleField('addressId', '45879')

1 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/module-customer\/Model\/ResourceModel\/AddressRepository.php(166): Magento\Customer\Model\AddressRegistry->retrieve('45879')

2 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/module-persistent\/Observer\/EmulateCustomerObserver.php(105): Magento\Customer\Model\ResourceModel\AddressRepository->getById('45879')

The addressID is different every time. And the only way to fix it for that person, is to just clear the cookies. Once you clear your cookies for the domain everything works perfectly fine again. It almost seems like something on the cookies is getting corrupt. It's pretty rare that it happens but we have a busy store, so rare is still 2-5 times a day.

Preconditions

  1. Magento 2.2.3
  2. PHP v 7.0.23
  3. Percona
  4. Managed Magento server at Nexcess

Steps to reproduce

I have not managed to figure out reliable steps to reproduce. Appears to be random

Expected result

  1. It shouldn't produce an error?

Actual result

{"0":"No such entity with addressId = 45879","1":"#0 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/module-customer\/Model\/AddressRegistry.php(49): Magento\Framework\Exception\NoSuchEntityException::singleField('addressId', '45879')\n#1 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/module-customer\/Model\/ResourceModel\/AddressRepository.php(166): Magento\Customer\Model\AddressRegistry->retrieve('45879')\n#2 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/module-persistent\/Observer\/EmulateCustomerObserver.php(105): Magento\Customer\Model\ResourceModel\AddressRepository->getById('45879')\n#3 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/Event\/Invoker\/InvokerDefault.php(72): Magento\Persistent\Observer\EmulateCustomerObserver->execute(Object(Magento\Framework\Event\Observer))\n#4 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/Event\/Invoker\/InvokerDefault.php(60): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Magento\Persistent\Observer\EmulateCustomerObserver), Object(Magento\Framework\Event\Observer))\n#5 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/Event\/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))\n#6 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/generated\/code\/Magento\/Framework\/Event\/Manager\/Proxy.php(95): Magento\Framework\Event\Manager->dispatch('controller_acti...', Array)\n#7 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/App\/Action\/Action.php(96): Magento\Framework\Event\Manager\Proxy->dispatch('controller_acti...', Array)\n#8 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))\n#9 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\Cms\Controller\Index\Index\Interceptor->___callParent('dispatch', Array)\n#10 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\Cms\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#11 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/generated\/code\/Magento\/Cms\/Controller\/Index\/Index\/Interceptor.php(39): Magento\Cms\Controller\Index\Index\Interceptor->___callPlugins('dispatch', Array, Array)\n#12 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/App\/FrontController.php(55): Magento\Cms\Controller\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#13 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))\n#14 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)\n#15 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/module-store\/App\/FrontController\/Plugin\/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#16 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n#17 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/module-page-cache\/Model\/App\/FrontController\/BuiltinPlugin.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#18 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n#19 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#20 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/generated\/code\/Magento\/Framework\/App\/FrontController\/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, NULL)\n#21 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/App\/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#22 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/generated\/code\/Magento\/Framework\/App\/Http\/Interceptor.php(24): Magento\Framework\App\Http->launch()\n#23 \/chroot\/home\/wonderci\/retailer.wondercide.com\/html\/vendor\/magento\/framework\/App\/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch()\n#24 \/chroot\/home\/wonderci\/wondercide.com\/html\/index.php(43): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#25 {main}","url":"\/","script_name":"\/index.php"}

Additional Information

The issue is not trivial and reproducible only in specific condition(s) or situation.
Here is the summary based investigation and comments

Fixed in 2.4.x Confirmed ready for confirmation P1 done Reported on 2.2.x Reproduced on 2.4.x S1

Most helpful comment

issue still persists on 2.3.2

All 57 comments

Did you find a solution? I am facing the same issue, but cannot find a way to reproduce it.

@hunterallen No I haven't found a solution. Appears to happen randomly. If a customer calls us about the issue, having them clear their cookies solves the issue. I have no idea why it happens or how to prevent it. But the problem is being caused in the cookies.

What happened to me was that a customer was checking out with a new shipping address and a new (but different from shipping) billing address. Once I manually added the address to that customers account the error went away.

I am also having the same error. Only happens for customers who are logged in.

I have this when I try to create an order in the admin for customers that have an account.

I'm using Magento 2.2.5. The error is:

No such entity with addressId =

Note that the customer has an account and an address, and use for shipping address the "use same as billing address" is checked.

I found the problem.
This happen if new customer have fail transaction payment on first time.
so the customer id and address id not connect.

how to reproduce :

  • Change payment key (public key or private key) so, transaction always fail
  • create new customer
  • make transaction
  • make payment -> result is fail
  • Change back payment key
  • make payment -> result success
  • sign out (Error No such entity with addressId = xxx)
  • Clear cookie
  • Sign In back
  • SIgn Out (Error No such entity with addressId = xxx)

I don't how to fix it. hope someone can help to fix it

Thank you

Hi @InternetMedicineMan thank you for you report, the fix for this issue has already on 2.2-develop and 2.3-develop branch

@engcom-backlog-nazar can you confirm which PR it was that fixed this issue please?

@adamj88 No i can't find any commit, but tested it on 2.2-develop branch, the issue not exist

Hi, is this bug fixed?

I am also facing this problem, does anyone have a fix?

issues occurs where the default billing address id and default shipping address id in the customer table do not actually match up to an address record as address record creation failed. this throws the "No such entity with address Id = ####" error on login / logout

to correct this a modification is need to public function execute in Magento\Persistent\Observer\EmulateCustomerObserver so that the $this->addressRepository->getById calls are executed in a try catch and if a no such entity exception is trapped in the catch update the related customer record to a null value for the related address id column.

P.S. I had the issue occur in Magento Version 2.2.6

resolution outline (not tested code):-

EXISTING
image

SUGGESTED
image

This issue is present in 2.2.6 @engcom-backlog-andrii @engcom-backlog-nazar @engcom-backlog-nickolas @engcom-backlog-pb

As mentioned above a failed checkout with new address is causing this issue

1 exception(s):
Exception #0 (Magento\Framework\Exception\NoSuchEntityException): No such entity with addressId = 8

Exception #0 (Magento\Framework\Exception\NoSuchEntityException): No such entity with addressId = 8
#0 /var/www/site.com/vendor/magento/module-customer/Model/AddressRegistry.php(49): Magento\Framework\Exception\NoSuchEntityException::singleField('addressId', '8')
#1 /var/www/site.com/vendor/magento/module-customer/Model/ResourceModel/AddressRepository.php(168): Magento\Customer\Model\AddressRegistry->retrieve('8')
#2 /var/www/site.com/vendor/magento/module-persistent/Observer/EmulateCustomerObserver.php(90): Magento\Customer\Model\ResourceModel\AddressRepository->getById('8')
#3 /var/www/site.com/vendor/magento/framework/Event/Invoker/InvokerDefault.php(72): Magento\Persistent\Observer\EmulateCustomerObserver->execute(Object(Magento\Framework\Event\Observer))
#4 /var/www/site.com/vendor/magento/framework/Event/Invoker/InvokerDefault.php(60): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Magento\Persistent\Observer\EmulateCustomerObserver), Object(Magento\Framework\Event\Observer))
#5 /var/www/site.com/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))
#6 /var/www/site.com/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch('controller_acti...', Array)
#7 /var/www/site.com/vendor/magento/framework/App/Action/Action.php(96): Magento\Framework\Event\Manager\Proxy->dispatch('controller_acti...', Array)
#8 /var/www/site.com/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#9 /var/www/site.com/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Controller\Category\View\Interceptor->___callParent('dispatch', Array)
#10 /var/www/site.com/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Controller\Category\View\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#11 /var/www/site.com/generated/code/Magento/Catalog/Controller/Category/View/Interceptor.php(39): Magento\Catalog\Controller\Category\View\Interceptor->___callPlugins('dispatch', Array, Array)
#12 /var/www/site.com/vendor/magento/framework/App/FrontController.php(55): Magento\Catalog\Controller\Category\View\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#13 /var/www/site.com/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#14 /var/www/site.com/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#15 /var/www/site.com/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#16 /var/www/site.com/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#17 /var/www/site.com/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#18 /var/www/site.com/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#19 /var/www/site.com/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#20 /var/www/site.com/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#21 /var/www/site.com/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#22 /var/www/site.com/vendor/magento/framework/App/Bootstrap.php(257): Magento\Framework\App\Http->launch()
#23 /var/www/site.com/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#24 {main}

Hi,

There is a fix for it, Actually quote_address table have some non exist customer_address_id column records, we need to set NULL to those records. Below is query for the same.

UPDATE quote_address SET customer_address_id=NULL where address_id IN ( select address_id from quote_address where ( customer_address_id is NOT NULL AND customer_address_id NOT IN ( select entity_id from customer_address_entity)) );

Thanks

Hi,

There is a fix for it, Actually quote_address table have some non exist customer_address_id column records, we need to set NULL to those records. Below is query for the same.

UPDATE quote_address SET customer_address_id=NULL where address_id IN ( select address_id from quote_address where ( customer_address_id is NOT NULL AND customer_address_id NOT IN ( select entity_id from customer_address_entity)) );

Thanks

The fact that it becomes necessary to run a DB query shows that there is something wrong with the code.

Can confirm this issue is not resolved in Magento 2.3.0. The database query provided updates zero entries for my installation.

[2018-12-14 18:52:44] main.WARNING: No such entity with addressId =

0 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/module-customer/Model/AddressRegistry.php(49): Magento\Framework\Exception\NoSuchEntityException::singleField('addressId', NULL)

1 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/module-customer/Model/ResourceModel/AddressRepository.php(172): Magento\Customer\Model\AddressRegistry->retrieve(NULL)

2 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/vertex/module-tax/Model/AddressDeterminer.php(88): Magento\Customer\Model\ResourceModel\AddressRepository->getById(NULL)

3 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/vertex/module-tax/Model/AddressDeterminer.php(67): Vertex\Tax\Model\AddressDeterminer->getDefaultBilling(2)

4 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/vertex/module-tax/Model/VertexUsageDeterminer.php(61): Vertex\Tax\Model\AddressDeterminer->determineAddress(Object(Magento\Customer\Model\Data\Address), 2, true)

5 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/vertex/module-tax/Model/Plugin/TaxCalculationPlugin.php(132): Vertex\Tax\Model\VertexUsageDeterminer->shouldUseVertex('1', Object(Magento\Customer\Model\Data\Address), 2, true)

6 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/vertex/module-tax/Model/Plugin/TaxCalculationPlugin.php(65): Vertex\Tax\Model\Plugin\TaxCalculationPlugin->useVertex(Object(Magento\Tax\Model\Sales\Quote\QuoteDetails), '1', true)

7 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/Interception/Interceptor.php(135): Vertex\Tax\Model\Plugin\TaxCalculationPlugin->aroundCalculateTax(Object(Magento\Tax\Model\TaxCalculationInterceptor), Object(Closure), Object(Magento\Tax\Model\Sales\Quote\QuoteDetails), '1')

8 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Tax\Model\TaxCalculationInterceptor->Magento\FrameworkInterception{closure}(Object(Magento\Tax\Model\Sales\Quote\QuoteDetails), '1')

9 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Tax/Model/TaxCalculation/Interceptor.php(26): Magento\Tax\Model\TaxCalculationInterceptor->___callPlugins('calculateTax', Array, NULL)

10 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/module-tax/Model/Sales/Total/Quote/Tax.php(209): Magento\Tax\Model\TaxCalculationInterceptor->calculateTax(Object(Magento\Tax\Model\Sales\Quote\QuoteDetails), '1')

11 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/module-tax/Model/Sales/Total/Quote/Tax.php(113): Magento\Tax\Model\Sales\Total\Quote\Tax->getQuoteTaxDetails(Object(Magento\Quote\Model\ShippingAssignment), Object(Magento\Quote\Model\Quote\Address\Total), true)

12 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Tax/Model/Sales/Total/Quote/Tax/Interceptor.php(24): Magento\Tax\Model\Sales\Total\Quote\Tax->collect(Object(Magento\Quote\Model\QuoteInterceptor), Object(Magento\Quote\Model\ShippingAssignment), Object(Magento\Quote\Model\Quote\Address\Total))

13 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/module-quote/Model/Quote/TotalsCollector.php(265): Magento\Tax\Model\Sales\Total\Quote\TaxInterceptor->collect(Object(Magento\Quote\Model\QuoteInterceptor), Object(Magento\Quote\Model\ShippingAssignment), Object(Magento\Quote\Model\Quote\Address\Total))

14 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/module-quote/Model/Quote/TotalsCollector.php(144): Magento\Quote\Model\Quote\TotalsCollector->collectAddressTotals(Object(Magento\Quote\Model\QuoteInterceptor), Object(Magento\Quote\Model\Quote\Address))

15 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/module-quote/Model/Quote.php(1984): Magento\Quote\Model\Quote\TotalsCollector->collect(Object(Magento\Quote\Model\QuoteInterceptor))

16 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Quote/Model/Quote/Interceptor.php(1064): Magento\Quote\Model\Quote->collectTotals()

17 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/module-msrp/Block/Total.php(51): Magento\Quote\Model\QuoteInterceptor->collectTotals()

18 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Msrp\Block\Total->_toHtml()

19 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Element\AbstractBlock->toHtml()

20 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(533): Magento\Framework\View\Layout->_renderBlock('checkout.cart.t...')

21 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.t...')

22 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\LayoutInterceptor->renderNonCachedElement('checkout.cart.t...')

23 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('checkout.cart.t...', false)

24 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\LayoutInterceptor->renderElement('checkout.cart.t...', false)

25 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout->_renderContainer('checkout.cart.t...', false)

26 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.t...')

27 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\LayoutInterceptor->renderNonCachedElement('checkout.cart.t...')

28 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('checkout.cart.t...', false)

29 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\LayoutInterceptor->renderElement('checkout.cart.t...', false)

30 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout->_renderContainer('cart.summary', false)

31 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('cart.summary')

32 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\LayoutInterceptor->renderNonCachedElement('cart.summary')

33 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('cart.summary', false)

34 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\LayoutInterceptor->renderElement('cart.summary', false)

35 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout->_renderContainer('checkout.cart.c...', false)

36 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.c...')

37 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\LayoutInterceptor->renderNonCachedElement('checkout.cart.c...')

38 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('checkout.cart.c...', false)

39 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\LayoutInterceptor->renderElement('checkout.cart.c...', false)

40 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout->_renderContainer('checkout.cart.i...', false)

41 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.i...')

42 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\LayoutInterceptor->renderNonCachedElement('checkout.cart.i...')

43 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('checkout.cart.i...', true)

44 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Element/AbstractBlock.php(508): Magento\Framework\View\LayoutInterceptor->renderElement('checkout.cart.i...', true)

45 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/module-checkout/view/frontend/templates/cart.phtml(15): Magento\Framework\View\Element\AbstractBlock->getChildHtml('with-items')

46 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/Users/patricsk...')

47 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Checkout\Block\Cart), '/Users/patricsk...', Array)

48 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template->fetchView('/Users/patricsk...')

49 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Framework\View\Element\Template->_toHtml()

50 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Element\AbstractBlock->toHtml()

51 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(533): Magento\Framework\View\Layout->_renderBlock('checkout.cart')

52 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart')

53 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\LayoutInterceptor->renderNonCachedElement('checkout.cart')

54 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('checkout.cart', false)

55 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\LayoutInterceptor->renderElement('checkout.cart', false)

56 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout->_renderContainer('content', false)

57 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('content')

58 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\LayoutInterceptor->renderNonCachedElement('content')

59 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('content', false)

60 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\LayoutInterceptor->renderElement('content', false)

61 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout->_renderContainer('main', false)

62 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('main')

63 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\LayoutInterceptor->renderNonCachedElement('main')

64 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('main', false)

65 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\LayoutInterceptor->renderElement('main', false)

66 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout->_renderContainer('columns', false)

67 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('columns')

68 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\LayoutInterceptor->renderNonCachedElement('columns')

69 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('columns', false)

70 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\LayoutInterceptor->renderElement('columns', false)

71 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout->_renderContainer('main.content', false)

72 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('main.content')

73 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\LayoutInterceptor->renderNonCachedElement('main.content')

74 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('main.content', false)

75 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\LayoutInterceptor->renderElement('main.content', false)

76 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout->_renderContainer('page.wrapper', false)

77 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper')

78 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\LayoutInterceptor->renderNonCachedElement('page.wrapper')

79 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('page.wrapper', false)

80 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\LayoutInterceptor->renderElement('page.wrapper', false)

81 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout->_renderContainer('root', false)

82 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('root')

83 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\LayoutInterceptor->renderNonCachedElement('root')

84 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('root', true)

85 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Layout.php(954): Magento\Framework\View\LayoutInterceptor->renderElement('root')

86 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Layout->getOutput()

87 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\LayoutInterceptor->___callParent('getOutput', Array)

88 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\LayoutInterceptor->Magento\FrameworkInterception{closure}()

89 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Layout/Interceptor.php(494): Magento\Framework\View\LayoutInterceptor->___callPlugins('getOutput', Array, Array)

90 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Result/Page.php(258): Magento\Framework\View\LayoutInterceptor->getOutput()

91 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/View/Result/Layout.php(171): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\HttpInterceptor))

92 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\HttpInterceptor))

93 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Result\PageInterceptor->___callParent('renderResult', Array)

94 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Result\PageInterceptor->Magento\FrameworkInterception{closure}(Object(Magento\Framework\App\Response\HttpInterceptor))

95 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(130): Magento\Framework\View\Result\PageInterceptor->___callPlugins('renderResult', Array, Array)

96 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/App/Http.php(139): Magento\Framework\View\Result\PageInterceptor->renderResult(Object(Magento\Framework\App\Response\HttpInterceptor))

97 /Users/patricskigen/sites/mg/peruvianlink/public/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()

98 /Users/patricskigen/sites/mg/peruvianlink/public/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\HttpInterceptor->launch()

99 /Users/patricskigen/sites/mg/peruvianlink/public/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\HttpInterceptor))

100 /Users/patricskigen/.composer/vendor/laravel/valet/server.php(151): require('/Users/patricsk...')

101 {main} [] []

Got the same issue, when I was trying to update customer from magento backend.

Magento ver. 2.2.5

main.WARNING: No such entity with addressId =

0 /vendor/magento/module-customer/Model/AddressRegistry.php(49): Magento\Framework\Exception\NoSuchEntityException::singleField('addressId', NULL)

1 /vendor/magento/module-customer/Model/ResourceModel/AddressRepository.php(166): Magento\Customer\Model\AddressRegistry->retrieve(NULL)

I hope someone can help to fix it.

@pskigen ... are you running a fresh install of 2.3 or an upgrade from a previous version?

Same problem here.. it is an upgrade from 2.2.6 to 2.2.7

Same issue here v2.2.5, I have not done any upgrades recently.

@Daniel304 ... If you upgrade to 2.2.7, then there is a probability that there will be an old quote from 2.2.6 with an invalid address id which would trigger this error again.

I would recommend deleting all orphans address_id using https://github.com/magento/magento2/issues/15115#issuecomment-442014255 and if the issue persists then it is still an issue

Using the query didn't help for us, we are at 2.2.7.

@srenon it was an upgrade from 2.2.5. The site is still in development, so there were only a few customer addresses. I believe it was resolved by removing those addresses and reentering them after the upgrade.

Obviously that's not much of a solution for anyone with an active shop with dozens, hundreds or even thousands of customers.

Can confirm this issue is not resolved in Magento 2.3.0. The database query provided updates zero entries for my installation.

[2018-12-14 18:52:44] main.WARNING: No such entity with addressId =

When the addressId is empty / NULL like above, it is like this:

In our case these errors are logged by new customers that signed up for an account, but not filled out an address yet.
The number between the brackets behind : _getDefaultBilling_ of _getDefaultShipping_ is the entity_id of the customer concerned. Which can be found in table 'customer_identity'

That way you can determine what customer is causing the errors, you can check the addresses and you could contact the customer to ask if he had any issues on your front end.

After filling out billing and shipping addresses for the customers account, the error will disappear.

Can confirm this issue is not resolved in Magento 2.2.7.

Existing and new customer still getting this error.

Since upgrading to Magento 2.27, I'm seeing this error occurring 50-100 times a day:
_No such entity with addressId = #0_

Haven't had any more customers complaining about the site than normal, just started getting this error like mad now.

I can still run the DB query to clear all orphan address_id's but they reoccur every day also, and if anyone gets an error with an error to the address_id that isn't zero, then that's when it seems to affect the customer's ability to use the site more.

Same issue on v2.2.4 but we are unable to upgrade yet as we are mid-process of migrating away from a theme that breaks on newer versions. (we'd prefer not dedicate more time to 'fixing' a broken theme we are trying to migrate away from anyway just to upgrade)

Is there a patch available that can be loaded via composer with cweagans module?

After some debugging, they seem to be 2 different issues reference in this ticket.

  1. quote_address - where customer_address_id has an invalid address id.

  2. customer_entity - where default_shipping or default_billing has an invalid address id

    • To test for this issue try running the following sql.

select * from customer_entity where default_shipping not in (select entity_id from customer_address_entity);

select * from customer_entity where default_billing not in (select entity_id from customer_address_entity);

To replicate this issue:
a. Enable "Persistent Shopping Cart" or Persistent History - (EE Users)
b. Log in as one of the user listed in the sql above (or set the default_billing in customer_entity to an address id that does not exist and then log in).
c. Wait for your customer session to expired or log out (did not test log out)
d. visit any page on the site and you should get the error.

99% of the customers with this issue was created in 2016-2017 in our database, so it may be an issue in older versions of Magento.

A temporary solution would be to set these ids to null in customer_entity table or apply https://github.com/magento/magento2/issues/15115#issuecomment-433029168 for CE. For EE you will need to also modify Magento\PersistentHistory\Model\CustomerEmulator

Hi,

There is a fix for it, Actually quote_address table have some non exist customer_address_id column records, we need to set NULL to those records. Below is query for the same.

UPDATE quote_address SET customer_address_id=NULL where address_id IN ( select address_id from quote_address where ( customer_address_id is NOT NULL AND customer_address_id NOT IN ( select entity_id from customer_address_entity)) );

Thanks

There is a problem in Query,
I am getting below error after running the above query.

SQLSTATE[HY000]: General error: 1093 You can't specify target table 'quote_address' for update in FROM clause,

Hey @jafar247commerce for mysql/mariadb use this syntax to fix non existent customer_address_id records by wrapping subquery in tblTmp:

UPDATE quote_address SET customer_address_id=NULL where address_id IN (SELECT * FROM( select address_id from quote_address where ( customer_address_id is NOT NULL AND customer_address_id NOT IN ( select entity_id from customer_address_entity)) )tblTmp);

For convenience here also is the fix for missing customer_address_entity record for default_billing and default_shipping:

UPDATE customer_entity SET default_billing=NULL where default_billing is NOT NULL AND default_billing not in (select entity_id from customer_address_entity);

UPDATE customer_entity SET default_shipping=NULL where default_shipping is NOT NULL AND default_shipping not in (select entity_id from customer_address_entity);

I've tried both of these and it did not permanently resolve the issue. So I am next testing this code in ./vendor/magento/module-persistent/Observer/EmulateCustomerObserver.php … wrapping $this->addressRepository->getById in try/cache adapted from @J-SM's post:

public function execute(\Magento\Framework\Event\Observer $observer)
 {
(...snip...)
        try {
            $address = $this->addressRepository->getById($defaultShipping);
        } catch(\Magento\Framework\Exception\NoSuchEntityException $ex){
            $address = null;
            $customer->setDefaultShipping($address);
            $this->_customerSession->setDefaultTaxShippingAddress(null);
        }
(...snip...)
        try {
                $address = $this->addressRepository->getById($defaultBilling);
        } catch(\Magento\Framework\Exception\NoSuchEntityException $ex){
            $address = null;
            $customer->setDefaultBilling($address);
            $this->_customerSession->setDefaultTaxBillingAddress(null);
        }   
(...snip...)

This is an ongoing and serious issue reported by multiple people, so thanks everyone for sharing their findings and solutions!

Maybe the correct way to fix this would be to set the address_id null on delete using mysql.

Magento\Customer\Setup

->addForeignKey(
        $installer->getFkName('customer_entity', 'default_billing', 'customer_address_entity', 'entity_id'),
        'default_billing',
        $installer->getTable('customer_address_entity'),
        'entity_id',
        \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)

->addForeignKey(
        $installer->getFkName('customer_entity', 'default_shipping', 'customer_address_entity', 'entity_id'),
        'default_billing',
        $installer->getTable('customer_address_entity'),
        'entity_id',
        \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)

Magento\Quote\Setup

->addForeignKey(
        $installer->getFkName('quote_address', 'customer_address_id', 'customer_address_entity', 'entity_id'),
        'customer_address_id',
        $installer->getTable('customer_address_entity'),
        'entity_id',
        \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
    )

Here is another way to reproduce the error:

  1. Sign in with a customer who have some addresses registered
  2. Sign in in the BO, edit this customer and remove all addresses
  3. Refresh the front (or browse whatever page)

To fix it I've made a rewrite of the function retrieve in class \Magento\Customer\Model\AddressRegistry :

From this:

    $address->load($addressId);
    if (!$address->getId()) {
        throw NoSuchEntityException::singleField('addressId', $addressId);
    }

To this

//if addressId is null or 0 we don't try to load it to avoid annoying log

if($addressId != 0 && $addressId != null){
    $address->load($addressId);
    if (!$address->getId()) {
        throw NoSuchEntityException::singleField('addressId', $addressId);
    }
}

I'm facing this same issue in EE 2.2.8 as well.

Does anyone also face the issue that a new password is unable to be set with this issue?

Any update to a fix on this issue? Using 2.3

I've been plagued with this issue since we launched M2.2 last year. Our setup was a migration from M1 > M2. The issue appears in the system.log a few times a day. However, no customers or admins have ever reported it. Based on my migration experience so far, I always assumed it only affected customers created in M1, but this isn't actually the case.

Anyway, I was finally able to reproduce the issue:

  1. Locate one of the affected customers in the system.log
  2. Create a New Order in the backend
  3. Select the affected customer from the list of existing customers

As soon as I selected the customer, the log was updated with the issue. Despite the log entry, I didn't see any issues on the backend.

Now that I was able to finally reproduce the issue, I decided to carry out a test. In the log, the issue mentions the Vertex Module. This isn't something we utilise, so I figured I'd disable the module. After that, I was unable to reproduce the issue.

For me, this feels like a safer fix to deploy in my Production environment that overriding any core code or running SQL queries I don't fully understand. I'm not entirely sure if I've fixed the Base Issue or the Symptom. But I figured I'd share what I'd learned in case it helps with your own investigations.

@engcom-backlog-nazar it is ridiculous that the status of this issue is closed when it is so clearly happening in every version of Magento 2.2 and from replies in this thread Magento 2.3 as well, wayy after Magento has said it's been "fixed" and therefore closed. Does anyone from Magento have any updates on this at all?

UPDATE quote_address SET customer_address_id=NULL where address_id IN ( select address_id from quote_address where ( customer_address_id is NOT NULL AND customer_address_id NOT IN ( select entity_id from customer_address_entity)) );

Query gives this sql error

You can't specify target table 'quote_address' for update in FROM clause

I have created an extension as per the above solutions, which worked for me

https://github.com/vinaysikarwar/AddressIssue

UPDATE quote_address SET customer_address_id=NULL where address_id IN ( select address_id from quote_address where ( customer_address_id is NOT NULL AND customer_address_id NOT IN ( select entity_id from customer_address_entity)) );

Query gives this sql error

You can't specify target table 'quote_address' for update in FROM clause

fix qry via named subquery (force MySQL to use temp table) I.e.

UPDATE quote_address SET customer_address_id=NULL where address_id IN ( select address_id from (select * from quote_address) as QA where ( QA.customer_address_id is NOT NULL AND QA.customer_address_id NOT IN ( select entity_id from customer_address_entity) ) );

That is not a solution to do things forcely. Its better to do it via try
catch.

On Wed, Jul 3, 2019, 11:16 PM J-SM notifications@github.com wrote:

UPDATE quote_address SET customer_address_id=NULL where address_id IN (
select address_id from quote_address where ( customer_address_id is NOT
NULL AND customer_address_id NOT IN ( select entity_id from
customer_address_entity)) );

Query gives this sql error

You can't specify target table 'quote_address' for update in FROM clause

fix qry via named subquery (force MySQL to use temp table) I.e.

UPDATE quote_address SET customer_address_id=NULL where address_id IN (
select address_id from (select * from quote_address) as QA where (
QA.customer_address_id is NOT NULL AND QA.customer_address_id NOT IN (
select entity_id from customer_address_entity) ) );

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/magento/magento2/issues/15115?email_source=notifications&email_token=ABJPGZBY3IJJXORGKQN4ZYDP5TQWZA5CNFSM4E7CYAIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZFGD4A#issuecomment-508191216,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABJPGZCZRFEXO5M7NLD4HULP5TQWZANCNFSM4E7CYAIA
.

Still got such warning message in the debug.log for version 2.2.9 when signing up new customers.

Still exists on 2.3.2

issue still persists on 2.3.2

M2.2.8

We are using https://github.com/magento/magento2/issues/15115#issuecomment-433029168 but without $customer->save() as there is no save method for the customer object.

M2.2.8

We are using #15115 (comment) but without $customer->save() as there is no save method for the customer object.

Is the #15115 comment working out for you?

We are getting this issue in production with Magento Enterprise 233 code. After some investigation, i have found this is happening for us in below scenario :

  1. Customer has account with us (say General account) but do not have any address assigned yet.
  2. They go through checkout process add add billing and shipping addresses
  3. They tick Save in address book option for their address added in checkout
  4. They click place order button and after adding payment details in Cybersource, PayPal etc but the order is not successful. The order declined for various reason (low stock, wrong card etc)
  5. They redirect to My cart page and again go to checkout steps.
  6. In shipping page when they press next they will get error message No such entity addressId = <some value>
  7. They can not move forward to complete the checkout because of this error.

After some investigation i have seen that the issue is coming from below class:
src/vendor/magento/module-quote/Model/QuoteManagement.php
If there is some exception in submitQuote method in this class , it catches the exception and executes $this->rollbackAddresses($quote, $order, $e); .
This method seems to be removing the address saved by customer during checkout from address repository but the reference of the addresses that are saved in customer_entity table as default address is not removed. This cases the error because the address related with those ids are not in database.
Magento support team provided patch for the Vertex module but we are not using this module. I am still getting this issue and trying to fix it. If anyone has solution please let me know.

The rollbackAddresses method looks as below
private function rollbackAddresses( QuoteEntity $quote, \Magento\Sales\Api\Data\OrderInterface $order, \Exception $e ): void { try { if (!empty($this->addressesToSync)) { foreach ($this->addressesToSync as $addressId) { $this->addressRepository->deleteById($addressId); } } $this->eventManager->dispatch( 'sales_model_service_quote_submit_failure', [ 'order' => $order, 'quote' => $quote, 'exception' => $e, ] ); // phpcs:ignore Magento2.Exceptions.ThrowCatch } catch (\Exception $consecutiveException) { $message = sprintf( "An exception occurred on 'sales_model_service_quote_submit_failure' event: %s", $consecutiveException->getMessage() ); // phpcs:ignore Magento2.Exceptions.DirectThrow throw new \Exception($message, 0, $e); } }
I do not understand why we will need to delete the address here. The customer is registered customer and they actually wanted to save those addresses. If i remove the code that deletes the addresses then my problems will be resolved but i will like to know any possible consequences of not removing the address when order place is failed. I will be very grateful if anyone will be able to explain me the negative impact of not deleting the address.

Thanks.

Any official solutions for this bug?

@sarjangautam Same to me on EE 2.3.4 the problem was not fixed on this version at all.

We really need a fix for this. Logged In customers with missing addresses can't continue the checkout process

Please re-open

!!
For those who want to clean-up the quote address table, please also remember that the customer_entity table has 2 columns (default_billing and default_shipping) that can also have a wrong reference
!!

Experiencing similar issues on Magento 2.4.1, why was this issue closed? As it is obviously still unresolved (based on the comments and experience).

Seems this issue has been closed by mistake
Reopen it not fixed yet

Hi here! I have investigated an issue a little bit, agree that it's really hard to reproduce it, but I found steps to reproduce with some direct changes in the DB. And thank you guys for your comments, it helped a lot!

So, the following steps may help you to reproduce the issue:

  1. Configure persistent shopping cart with the following settings
    Screen Shot 2020-12-08 at 12 45 34
  1. Create a new customer and define default shipping and billing addresses.
  2. Log out
  3. Log in with "Remember me" checkbox applied.
  4. Go to customer_entity DB table and change default_billing and default_shipping ids to not existing ones.
  5. Log out

You will get a No such entity with addressId = error, caused by an exception in https://github.com/magento/magento2/blob/a31f4a35c018ad09654e5bd5871086b73fbd3d2d/app/code/Magento/Persistent/Observer/EmulateCustomerObserver.php#L90

To be honest, I don't know what caused the incorrect address id in the table, probably during the order submission process something went wrong, and customer addresses weren't saved, but the customer model has been updated at this moment.

So, the easy fix is to wrap https://github.com/magento/magento2/blob/a31f4a35c018ad09654e5bd5871086b73fbd3d2d/app/code/Magento/Persistent/Observer/EmulateCustomerObserver.php#L90 call into the try-catch block and update customer record/ignore incorrect address id.

The proper fix is to identify the root cause of the incorrect address ids and handle it to avoid incorrect data in DB at all.

The issue was investigated and prioritized today during a public triage meeting.

  • Issue very specific and does not have simple steps to reproduce
  • after review comments and code analyses it seems that the bug exists and should be fixed
  • initial description was updated - added links to the comment with possible steps to reproduce and result of the investigation
  • triaged and confirmed it as P1

:white_check_mark: Confirmed by @sdzhepa
Thank you for verifying the issue. Based on the provided information internal tickets MC-39765 were created

Issue Available: @sdzhepa, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

@magento i am working on it

Hi @InternetMedicineMan, @zakdma.

Thank you for your report and collaboration!

The related internal Jira ticket MC-39765 was closed as Fixed.

The fix will be available with the upcoming 2.4.3 release.

Was this page helpful?
0 / 5 - 0 ratings