-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fix "Invalid customer address id" error when customer_id and is_guest flag are out of sync #40246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
Co-authored-by: ihor-sviziev <1873745+ihor-sviziev@users.noreply.github.com>
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
Co-authored-by: ihor-sviziev <1873745+ihor-sviziev@users.noreply.github.com>
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
1 similar comment
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
| $this->doValidate($address, $cart->getCustomerIsGuest() ? null : (int) $cart->getCustomer()->getId()); | ||
| // If cart has a customer ID, use it regardless of the is_guest flag | ||
| // This handles cases where the flags are out of sync | ||
| $customer = $cart->getCustomer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot but this will lead to unexpected customer objeto load, which is quite expensive in termas of performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit b097dfc. Now using instanceof Quote check to call getCustomerId() directly, avoiding the expensive customer object load. Falls back to getCustomer()->getId() only for non-Quote CartInterface implementations.
Co-authored-by: ihor-sviziev <1873745+ihor-sviziev@users.noreply.github.com>
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
Co-authored-by: ihor-sviziev <1873745+ihor-sviziev@users.noreply.github.com>
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
1 similar comment
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
|
@magento run all tests |
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
Checkout fails with "Invalid customer address id" when a quote's
customer_idfield is set but theis_guestflag remains true, or vice versa. This state occurs during customer deletion/recreation with the same email or quote merging after login.Root Cause
QuoteAddressValidator::validateForCart()determines whether to validate against a customer ID by checking only theis_guestflag:When these flags are desynchronized, validation incorrectly treats a logged-in customer's cart as a guest cart (or vice versa), causing the address validation to fail with
NoSuchEntityException.Changes
is_guestflag, with performance optimization to avoid expensive customer object loadingPerformance
The fix uses
instanceof Quoteto directly accessgetCustomerId()in the common case, avoiding the expensivegetCustomer()call that loads the full customer object from the repository. This maintains optimal performance while fixing the synchronization issue.Impact
Fixes #23618. Addresses the same root cause as the previously attempted fix referenced in the issue comments.
Original prompt
This section details on the original issue you should resolve
<issue_title>Invalid address id at check out</issue_title>
<issue_description>
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
I get the error: Unable to save shipping information. Please check input data.
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)"} []
I removed the address from this customer and re-entered it. Ran the index etc. Nothing.
Other accounts are still ok with the checkout.
The table quote_address stays empty for this quote.</issue_description>
Comments on the Issue (you are @copilot in this section)
@magento-engcom-team Hi @krishprakash. Thank you for your request. I'm working on Magento 2.3-develop instance for you @magento-engcom-team Hi @krishprakash, here is your [Magento instance](https://i-23618-2-3-develop.instances.magento-community.engineering). Admin access: [https://i-23618-2-3-develop.instances.magento-community.engineering/admin](https://i-23618-2-3-develop.instances.magento-community.engineering/admin) Login: `admin` Password: `123123q` Instance will be terminated in up to 3 hours. @ I have this issue randomly on 2.3.1Test customer account with several saved addresses from testing the checkout, try to use one to checkout today, "Invalid customer address ID ..."</comment_new>
<comment_new>@magento-engcom-team
Hi @amanuni. Thank you for your request. I'm working on Magento 2.3-develop instance for you</comment_new>
<comment_new>@magento-engcom-team
Hi @amanuni, here is your Magento instance.
Admin access: https://i-23618-2-3-develop.instances.magento-community.engineering/admin
Login:
adminPassword:123123qInstance will be terminated in up to 3 hours.</comment_new>
<comment_new>@engcom-November
Hello @onepack,
Thank you for the report and collaboration!
Thank you@mamsincl for the input.
Tried to reproduce this issue on 2.4-develop, but it is not reproducible in our case.
We tried with different ways to reproduce as mentioned in the issue thread, but we did not see any error.
Could you please check if the issue is reproducible in latest version of magento, and please give the exact steps.
Thank you.</comment_new>
<comment_new>@engcom-November
Hello @onepack,
As there is no activity on this issue for a long time, we believe the issue has been resolved, hence closing this issue.
Feel free to raise a new issue or reopen this if you need more assistance.
Thank you.</comment_new>
<comment_new>@ihor-sviziev
@engcom-November, as you see, people are still complaining about this issue.
Did you try the following steps? #23618 (comment)
As for me, the fix from #23618 (comment) looks absolutely logical.
It feels like we're saving the quote by setting the customer ID but not marking it as not a guest. Then quote address validation happening and works incorrectly
magento2/app/code/Magento/Quote/Model/QuoteAddressValidator.php
Lines 154 to 160 in f4c3cdc
magento2/app/code/Magento/Quote/Model/QuoteAddressValidator.php
Lines 81 to 87 in f4c3cdc
<comment_new>@ihor-sviziev
I prepared a fix for this issue https://github.co...
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.