Invalid customer address ID error in Adobe Commerce

In Adobe Commerce, the Invalid customer address ID error occurs due to inconsistent data in the quote table. Specifically, some records contain both a valid customer_id and a customer_is_guest flag set to 1, which causes the customer address validation to fail. To fix this, identify and update the affected records in the database using SQL queries.

Description description

Environment

Adobe Commerce

Issue/Symptoms

  • An error is logged intermittently in New Relic with the following message:

    Magento\Framework\Exception\NoSuchEntityException: Invalid customer address id < ID> in /vendor/magento/module-quote/Model/QuoteAddressValidator.php

  • This issue occurs for random customers, and the steps to replicate it are unknown.

  • The error appears to be related to inconsistencies in the database where certain customer carts or quotes have conflicting data.

Resolution resolution

Note:  It is recommended to perform these actions during a maintenance window or when system activity is minimal to avoid disruptions.

To resolve the issue, follow these steps:

  1. Backup your database before making any changes.

  2. Identify affected records by running the following query:

    code language-none
      `SELECT count(*) FROM quote WHERE customer_id != 0 AND customer_is_guest = 1;`
    
  3. If affected records are found, update them by setting customer_is_guest to 0 for rows where customer_id != 0. Use the following SQL statement:

    code language-none
      `UPDATE quote SET customer_is_guest = 0 WHERE customer_id != 0 AND customer_is_guest = 1;`
    
  4. Verify that the changes have resolved the issue by monitoring logs and ensuring no further errors are logged.

If additional assistance is required, contact Adobe Support for further investigation.

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f