/cart/change.js don't return Checkout Validation Rule error like /cart/add.js

Topic summary

A developer has identified inconsistent error handling between Shopify’s /cart/add.js and /cart/change.js endpoints when Checkout Validation Rules are triggered.

The Issue:

  • /cart/add.js properly returns 422 status errors with structured JSON containing validation messages (e.g., “You can’t add purchase more than 1 pre-order product in your cart”)
  • /cart/change.js returns a 422 status but the response body doesn’t match the expected validation error format
  • When parsing the response body from /cart/change.js, the developer receives completely different data than expected

Current Status:

  • The developer questions whether this inconsistency is intentional or a bug
  • A second user confirms experiencing the same problem
  • Both are seeking solutions for handling cart updates after AJAX requests, particularly in the Dawn theme
  • No resolution or workaround has been provided yet

The discussion includes code snippets and screenshots demonstrating the discrepancy between the two endpoints’ error responses.

Summarized with AI on November 5. AI used: claude-sonnet-4-5-20250929.

I had a sample code like below

fetch('/cart/change.js', {
        method: 'POST',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          line,
          quantity,
          sections,
          sections_url
        })
      })
        .then(async (res) => {
            if (res.status === 422) {
               var body = await res.json(); 
               console.log('Body', body); 
               return res.json()
            }
            return res.text()
        })
        .then((json) => {
          console.log(json);
        })
        .catch((error) => {
          console.error('Error:', error);
        });

The code is just some sample. The errors I receive in my terminal. Is match with the errors in our Checkout Rule

However we actually receive something totally different when parse the body.

Is this intended or anyway we can get something like error response in /cart/add.js which work perfectly fine with Checkout Validation Rule

{
"status": 422,
"message": "Cart Error",
"description": "You can't add purchase than 1 pre-order product in your cart."
}

I am also looking the solution for this issue.

Shopify added the validation on storefront api that response is mostly 422 in case of fail that is big issue and stop the execution of theme after ajax request. Can any one helpe to know who dawn theme handle the cart drawer after add and change the cart item.

Thanks

Zain