Magento2: Invalid address id at check out

Created on 8 Jul 2019  路  23Comments  路  Source: magento/magento2

Preconditions (*)

  1. Magento 2.3.2
    2.

Steps to reproduce (*)

  1. Delete a customer and then re-create it with the same email.
  2. Go to checkout with a product in the basket.
  3. At sending press "next".

Expected result (*)

  1. The next step is supposed to load

Actual result (*)

  1. I get the error: Unable to save shipping information. Please check input data.
  2. Error log: [2019-07-08 10:33:00] main.CRITICAL: Invalid customer-address id 6 {"exception":"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): Invalid customer-address id 6 at /home/server/domains/dev3.domain.com/public_html/vendor/magento/module-quote/Model/QuoteAddressValidator.php:79)"} []
  1. I removed the address from this customer and re-entered it. Ran the index etc. Nothing.
  2. Other accounts are still ok with the checkout.
  3. The table quote_address stays empty for this quote.
Cannot Reproduce Format is valid P3 PR Created S3

Most helpful comment

I also have this issue with my test account in M 2.3.2. I don't know the root cause for it, so i added a work around for it as:
in magento/vendor/magento/module-quote/Model/QuoteAddressValidator.php
change the function validateForCart as
from :

 public function validateForCart(CartInterface $cart, AddressInterface $address): void
    {
        $this->doValidate($address, $cart->getCustomerIsGuest() ? null : $cart->getCustomer()->getId());
    }

to:

public function validateForCart(CartInterface $cart, AddressInterface $address): void
    {
        $this->doValidate($address, $cart->getCustomerId() ? $cart->getCustomer()->getId() : null );
    }

Please let me know its fine this change or any other patch are available for this.
Thanks!

All 23 comments

Hi @onepack. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@onepack do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Hi @krishprakash. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [ ] 6. Add label Issue: Confirmed once verification is complete.

  • [ ] 7. Make sure that automatic system confirms that report has been added to the backlog.

@magento give me 2.3-develop instance

Hi @krishprakash. Thank you for your request. I'm working on Magento 2.3-develop instance for you

Hi @krishprakash, here is your Magento instance.
Admin access: https://i-23618-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

Hi @onepack.
I'm not able to reproduce this issue as provided steps by you.
Please update the reproducible steps and kindly confirm that its reproducible on Vanilla Magento instance.
Thanks.

Hi @krishprakash ,

I tried to reproduce the same but was not able to.
The difference now is that as I remember there had been an update via an account import on this account in between.
I will need to check that.

But for now, is there anyone that can explain what is happening to that account and why I get this error on it?

Please feel free to reopen the issue if you reproduce on venilla instance.
Thanks

I have this issue randomly on 2.3.1

Test customer account with several saved addresses from testing the checkout, try to use one to checkout today, "Invalid customer address ID ..."

I can confirm that this is also happening at random in a commerce 2.3.2 version
error: Invalid customer address id 2 {"exception":"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): Invalid customer address id 2 at "path/to/server"/vendor/magento/module-quote/Model/QuoteAddressValidator.php:79)"} []

@magento give me 2.3-develop instance

Hi @amanuni. Thank you for your request. I'm working on Magento 2.3-develop instance for you

Hi @amanuni, here is your Magento instance.
Admin access: https://i-23618-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

It seems like this issue related to the customer id is missing.

Here is how it can be fixed locally: https://github.com/magento/magento2/issues/23908#issuecomment-515919094

The root cause is not yet clear but a solution for customers experiencing this issue is here:
https://github.com/magento/magento2/issues/23908#issuecomment-518875486

I also have this issue with my test account in M 2.3.2. I don't know the root cause for it, so i added a work around for it as:
in magento/vendor/magento/module-quote/Model/QuoteAddressValidator.php
change the function validateForCart as
from :

 public function validateForCart(CartInterface $cart, AddressInterface $address): void
    {
        $this->doValidate($address, $cart->getCustomerIsGuest() ? null : $cart->getCustomer()->getId());
    }

to:

public function validateForCart(CartInterface $cart, AddressInterface $address): void
    {
        $this->doValidate($address, $cart->getCustomerId() ? $cart->getCustomer()->getId() : null );
    }

Please let me know its fine this change or any other patch are available for this.
Thanks!

I added it below mention code at beginning of doValidate function.

        if(!$customerId){
            if($address->getCustomerId()){
                $customerId = $address->getCustomerId();
            }
        }

And its seems working fine.

Steps to reproduce:

  1. Add products to cart
  2. Go to checkout
  3. Add email id and login from the checkout page
  4. After login, click the next to go to the payment page.
  5. Error will popup with "The shipping information was unable to be saved. Verify the input data and try again."

When we check the quote table.

SELECT entity_id, customer_id FROM quote WHERE customer_id != 0 AND customer_is_guest = 1;
+-----------+-------------+
| entity_id | customer_id |
+-----------+-------------+
|        28 |           4 |
+-----------+-------------+

The cause is that the shopping cart has customer_is_guest = 1.
That causes Magento\Quote\Model'QuotaAddressValidator line 130 tot pass null to doValidate.

I suspect logging in should set customer_is_guest to 0 but doesn't or not always at least.

I don't know about you guys, but I guess I'm going to write another bugfix plugin.

@arnoutvreugdenhil I have the same problem and setting customer_is_guest to 0 fixes it. It is sporadic and seems to be related to the persistent cart.

Does anyone know how this is happening? I have some customers with that issue. No guest orders allowed - everyone need to register. So maybe theres an issue in the quote conversion after logging in? Occured in 2.3.2 - is it fixed in 2.3.3?

In my case I'm facing the same issue but that is related to an address set on quote entry that belongs to another customer.
Here a query example:
select qa.quote_id, qa.address_id as quote_address_id, cae.entity_id as customer_address_id, qa.customer_id as quote_customer_id, cae.parent_id as address_customer_id from quote_address as qa JOIN customer_address_entity as cae on (cae.entity_id=qa.customer_address_id) WHERE cae.parent_id!=qa.customer_id LIMIT 1000;

That will show the last 2 columns where is the quote_customer_id and the "address_customer_id" where is the customer related to the address entry set on address_id field on quote table.

Results in my case:
+----------+------------------+---------------------+-------------------+---------------------+
| quote_id | quote_address_id | customer_address_id | quote_customer_id | address_customer_id |
+----------+------------------+---------------------+-------------------+---------------------+
| 36508 | 78919 | 9789 | 9002 | 9003 |
| 36508 | 78920 | 9789 | 9002 | 9003 |
+----------+------------------+---------------------+-------------------+---------------------+

2 rows in set (0.72 sec)

Both customer id 9002 and 9003, in that case, one is the Admin Company user and the second is the normal company user.

I hope that helps anyone that is debugging it. I wasn't able to discover why or how that happened.

I was able to replicate this issue in 2.3.5-p1 with fresh 2.3.4 db upgrade.

One way to replicate this issue to to try:

  1. Disable guest checkout
  2. While still logged out, add an item to your cart (has this issue with downloadable product)
  3. Then click checkout
  4. On the log in screen. Log in with a customer that already has a save cart and billing info

The customer_is_guest will not get updated, which trigger the issue

Instead of PR #26637 we should consider correcting the data inconsistency which will also fix other issues by updating customer_is_guest before we submit a quote.

vendor/magento/module-quote/Model/QuoteManagement.php

Index: vendor/magento/module-quote/Model/QuoteManagement.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
---  vendor/magento/module-quote/Model/QuoteManagement.php  (date 1589668946000)
+++  vendor/magento/module-quote/Model/QuoteManagement.php  (date 1589668946000)
@@ -494,6 +494,12 @@
      */
     protected function submitQuote(QuoteEntity $quote, $orderData = [])
     {
+        if ($quote->getCustomer()->getId()) {
+            $quote->setCustomerIsGuest(0);
+        } else {
+            $quote->setCustomerIsGuest(1);
+        }
+
         $order = $this->orderFactory->create();
         $this->submitQuoteValidator->validateQuote($quote);
         if (!$quote->getCustomerIsGuest()) {
Was this page helpful?
0 / 5 - 0 ratings