Magento2: Checkout/Cart visit results in error (500) after update 2.2.1 -> 2.2.2

Created on 12 Dec 2017  路  32Comments  路  Source: magento/magento2

Preconditions

  1. Using magento 2.2.2 (updated from 2.2.1), none of the new features.
  2. php, mysql and other libraries current from vanilla ubuntu 16.04

Steps to reproduce

  1. Populate cart, visist https://shop/checkout/cart

Expected result

  1. Get served a cart page as in magento 2.2.1

Actual result

  1. Magento answers with a snippet of shipping stuff (in our case translated "Versandgeb眉hren hier abrufen") in a block-shipping div nicely wrapped in a HTTP 500 response.
    The log shows:
2017/12/12 20:56:09 [error] 13026#13026: *1925924 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Magento\Quote\Model\Cart\Totals::setExtensionAttributes() must be an instance of Magento\Quote\Api\Data\TotalsExtensionInterface, instance of Magento\Quote\Api\Data\AddressExtension given, called in /var/www/XXX/vendor/magento/framework/Api/DataObjectHelper.php on line 125 and defined in /var/www/XXX/vendor/magento/module-quote/Model/Cart/Totals.php:592
Stack trace:
#0 /var/www/XXX/vendor/magento/framework/Api/DataObjectHelper.php(125): Magento\Quote\Model\Cart\Totals->setExtensionAttributes(Object(Magento\Quote\Api\Data\AddressExtension))
#1 /var/www/XXX/vendor/magento/framework/Api/DataObjectHelper.php(85): Magento\Framework\Api\DataObjectHelper->_setDataValues(Object(Magento\Quote\Model\Cart\Totals), Array, 'Magento\\Quote\\A...')
#2 /var/www/XXX/vendor/magento/module-quote/Model/Cart/CartTotalRepository.php(103): Magento\Framework\Api\DataObjectHelper->popu" while reading response header from upstream, client: 127.0.0.1, server: XXX, request: "GET /checkout/cart/ HTTP/1.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "XXX", referrer: "https://XXX/myproduct.html"
Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.2.x Reproduced on 2.3.x

Most helpful comment

I had the same issue and I have created a standalone magento module flancer32/mage2_fix_is12655 based on https://github.com/magento/magento2/commit/aa535e to fix it.

All 32 comments

This only happens if there are items in cart, once I delete them I see again a happy "empty cart"- kind of page. And not reproducibly so (well - only in a new incognito browser window it works fine).

Facing same problem

I can confirm the same problem arising on my magento2 installation after upgrading from 2.2.1 to 2.2.2. Downgrading back to 2.2.1 fixes the problem.

I am having the same issue as well.

I am having the same issue.

Magento 2.2.2 upgraded from 2.1.9

Happens with new or logged customers

Apache error log:

PHP Fatal error: Uncaught TypeError: Argument 1 passed to Magento\\Quote\\Model\\Cart\\Totals::setExtensionAttributes() must be an instance of Magento\\Quote\\Api\\Data\\TotalsExtensionInterface, instance of Magento\\Quote\\Api\\Data\\AddressExtension given, called in /var/www/www.mywebsite.com/public_html/vendor/magento/framework/Api/DataObjectHelper.php on line 125 and defined in /var/www/www.mywebsite.com/public_html/vendor/magento/module-quote/Model/Cart/Totals.php:592\nStack trace:\n#0 /var/www/www.mywebsite.com/public_html/vendor/magento/framework/Api/DataObjectHelper.php(125): Magento\\Quote\\Model\\Cart\\Totals->setExtensionAttributes(Object(Magento\\Quote\\Api\\Data\\AddressExtension))\n#1 /var/www/www.mywebsite.com/public_html/vendor/magento/framework/Api/DataObjectHelper.php(85): Magento\\Framework\\Api\\DataObjectHelper->_setDataValues(Object(Magento\\Quote\\Model\\Cart\\Totals), Array, 'Magento\\\\Quote\\\\A...')\n#2 /var/www/www.mywebsite.com/public_html/vendor/magento/module-quote/Model/Cart/CartTotalRepository.php(103): Magento\\F in /var/www/www.mywebsite.com/public_html/vendor/magento/module-quote/Model/Cart/Totals.php on line 592, referer: https://www.mywebsite.com/it/checkout/

image

Same issue. Only happens when your logged into a customer account with items in your cart.

I have this issue also if a payment failed after the customer returns to the cart page.

I have this issue after upgrading to 2.2.2 as well. Only happens for logged in users. Creating a new user account works for a time and then starts failing.

With PHP errors on the last output is:

window.checkoutConfig = <br />
--
聽 | <b>Fatal error</b>:  Uncaught TypeError: Argument 1 passed to Magento\Quote\Model\Cart\Totals::setExtensionAttributes() must be an instance of Magento\Quote\Api\Data\TotalsExtensionInterface, instance of Magento\Quote\Api\Data\AddressExtension given, called in /var/www/clients/client3/web4/web/vendor/magento/framework/Api/DataObjectHelper.php on line 125 and defined in /var/www/clients/client3/web4/web/vendor/magento/module-quote/Model/Cart/Totals.php:592
聽 | Stack trace:
聽 | #0 /var/www/clients/client3/web4/web/vendor/magento/framework/Api/DataObjectHelper.php(125): Magento\Quote\Model\Cart\Totals-&gt;setExtensionAttributes(Object(Magento\Quote\Api\Data\AddressExtension))
聽 | #1 /var/www/clients/client3/web4/web/vendor/magento/framework/Api/DataObjectHelper.php(85): Magento\Framework\Api\DataObjectHelper-&gt;_setDataValues(Object(Magento\Quote\Model\Cart\Totals), Array, 'Magento\\Quote\\A...')
聽 | #2 /var/www/clients/client3/web4/web/vendor/magento/module-quote/Model/Cart/CartTotalRepository.php(103): Magento\Framework\Api\DataObjectHelper-&gt;populateW in <b>/var/www/clients/client3/web4/web/vendor/magento/module-quote/Model/Cart/Totals.php</b> on line <b>592</b><br />

Downgrading to 2.2.1 solved the problem.

I am having the same issue.
Magento 2.2.2 upgraded from 2.1.10

@JonnyStecchino, @mombrea, @friimaind, @fwolfst, @cmuench, @twa8000, @webazad, @darinda This was an issue which had been fixed since 2.1.7 but for some reason it was not merged to 2.2.*. Here is the fix for it https://github.com/magento/magento2/commit/aa535e.

I've created a temporary plugin to fix this, so you could also do the same.

@ferrazzuk Awesome. confirm that fix works.

@ferrazzuk Hello, Can you add code of your plugin or link ?

Hello,
I am using Magento 2.2.2 installed from scratch, not updated from earlier version. I am still experiencing same issue. I tried this fix aa535e it doesn't help.

`Uncaught TypeError: Argument 1 passed to MagentoQuoteModelCartTotals::setExtensionAttributes() must be an instance of MagentoQuoteApiDataTotalsExtensionInterface, instance of MagentoQuoteApiDataAddressExtension given, called in /home/reachf90/public_html/dev18/vendor/magento/framework/Api/DataObjectHelper.php on line 125 and defined in /home/reachf90/public_html/dev18/vendor/magento/module-quote/Model/Cart/Totals.php:592
Stack trace:

0 /home/reachf90/public_html/dev18/vendor/magento/framework/Api/DataObjectHelper.php(125): MagentoQuoteModelCartTotals->setExtensionAttributes(Object(MagentoQuoteApiDataAddressExtension))

1 /home/reachf90/public_html/dev18/vendor/magento/framework/Api/DataObjectHelper.php(85): MagentoFrameworkApiDataObjectHelper->_setDataValues(Object(MagentoQuoteModelCartTotals), Array, 'Magento\Quote\A...')

2 /home/reachf90/public_html/dev18/vendor/magento/module-quote/Model/Cart/CartTotalRepository.php(103): MagentoFrameworkApiDataObjectHelper->populateWithAr in /home/reachf90/public_html/dev18/vendor/magento/module-quote/Model/Cart/Totals.php on line 592

{"messages":{"error":[{"code":500,"message":"Fatal Error: 'Uncaught TypeError: Argument 1 passed to Magento\Quote\Model\Cart\Totals::setExtensionAttributes() must be an instance of Magento\Quote\Api\Data\TotalsExtensionInterface, instance of Magento\Quote\Api\Data\AddressExtension given, called in /home/reachf90/public_html/dev18/vendor/magento/framework/Api/DataObjectHelper.php on line 125 and defined in /home/reachf90/public_html/dev18/vendor/magento/module-quote/Model/Cart/Totals.php:592nStack trace:n#0 /home/reachf90/public_html/dev18/vendor/magento/framework/Api/DataObjectHelper.php(125): Magento\Quote\Model\Cart\Totals->setExtensionAttributes(Object(Magento\Quote\Api\Data\AddressExtension))n#1 /home/reachf90/public_html/dev18/vendor/magento/framework/Api/DataObjectHelper.php(85): Magento\Framework\Api\DataObjectHelper->_setDataValues(Object(Magento\Quote\Model\Cart\Totals), Array, 'Magento\\Quote\\A...')n#2 /home/reachf90/public_html/dev18/vendor/magento/module-quote/Model/Cart/CartTotalRepository.php(103): Magento\Framework\Api\DataObjectHelper->populateWithAr' in '/home/reachf90/public_html/dev18/vendor/magento/module-quote/Model/Cart/Totals.php' on line 592","trace":"Trace is not available."}]}}`

Is there an estimated time for fix and release on this as its a pretty large issue, clearly affecting many people?

Thanks

I had the same issue and I have created a standalone magento module flancer32/mage2_fix_is12655 based on https://github.com/magento/magento2/commit/aa535e to fix it.

@fwolfst, thank you for your report.
We've acknowledged the issue and added to our backlog.

We are facing the same issues on upgrade from m2.2.1 -> m2.2.2.
The module of @flancer64 works for me! Thanks

Another confirmation that the issue exists and that @flancer64 's fix works perfectly.

In my case the issue appeared after update from 2.1.9 to 2.2.3, @flancer64 's fix worked.

Same issue here with 2.2.1 -> 2.2.3 @flancer64 is a star!

Same issue here. Upon a closer look, I found some behavior in \Magento\Checkout\Model\TotalsInformationManagement that did not align with similar procedures in the quote module. See excerpt from this class below:

/**
 * {@inheritDoc}
 */
public function calculate(
    $cartId,
    \Magento\Checkout\Api\Data\TotalsInformationInterface $addressInformation
) {
    /** @var \Magento\Quote\Model\Quote $quote */
    $quote = $this->cartRepository->get($cartId);
    $this->validateQuote($quote);

    if ($quote->getIsVirtual()) {
        $quote->setBillingAddress($addressInformation->getAddress());
    } else {
        $quote->setShippingAddress($addressInformation->getAddress());
        $quote->getShippingAddress()->setCollectShippingRates(true)->setShippingMethod(
            $addressInformation->getShippingCarrierCode() . '_' . $addressInformation->getShippingMethodCode()
        );
    }
    $quote->collectTotals();

    return $this->cartTotalRepository->get($cartId);
}

I'm not sure if this is intentional or what the logic is behind this, but the last 2 lines should be re-evaluated, to consider the following:

  • This is the only place where I find totals collection without a wrapping call to save by the repository
  • The quote is presumably reloaded by the repository on the return statement

I was able to solve my issue in a way different from @flancer64 by changing the totals collection call like so:

    $this->cartRepository->save($quote->collectTotals());

Alternatively you could return the prepared quote itself instead of reloading from the repository, but I'm unsure of the intention/design of this method to commit a save back on the record. I'd like to hear some thoughts from those more familiar with the architecture here.

Also experiencing this in 2.2.3

I am having this issue on checkout when user has an account for the first time then log out add to cart then at checkout enter email and password hit login I get exactly as described PHP Fatal error: Uncaught TypeError: Argument 1 passed to MagentoQuoteModelCartTotals::setExtensionAttributes() ....
instance of MagentoQuoteApiDataAddressExtension given ....

Is there a quick fix?

@lano-vargas have you tried my suggested fix on the core?

https://github.com/magento/magento2/issues/12655#issuecomment-371962845

It would be the "quick fix." Short of that, you can do something as an extension, via plugins:

  • Register plugin on webapi_rest/di.xml for \Magento\Checkout\Model\TotalsInformationManagement
  • Implement plugin with method aroundCalculate
  • Change behavior as I prescribed, such that you save the quote before returning it

Working on #dmcdindia

@popatkaran thank you for joining. Please accept team invitation here and self-assign the issue.

Same issue v. 2.2.2, fixed with your module @flancer64 thank you!

Thanks @flancer64 , Yous module fixed my issue in 2.2.3 :)

I have tested this on various versions, including 2.2.3 and 2.3-develop, and confirmed that this issue has been fixed. Below are the relevant pull requests:

Original fix in 2.1-develop (https://github.com/magento/magento2/commit/aa535e)
Forwardport to 2.2-develop (https://github.com/magento/magento2ce/pull/1975/files)
Forwardport to 2.3-develop (https://github.com/magento/magento2/pull/17620/files)

CC @okorshenko

Hi @RyanZolper Thank you for the research! 馃憤

Is this fixed in the latest versions? > 2.2.4? Just wondering if I would need to reapply the patch.

Was this page helpful?
0 / 5 - 0 ratings