Magento2: Checkout rules.js:56 Uncaught TypeError: Cannot read property 'length' of undefined

Created on 8 Jun 2016  路  68Comments  路  Source: magento/magento2

Having this issue on two magento installations ver. 2.0.4 and ver. 2.0.6. (the second one is a new installation without any modules, blank theme)

Steps to reproduce

  1. Proceed to checkout
  2. Fill in shipping information
  3. Choose shipping method
  4. Hit the "back" button on your web browser
  5. Click Proceed to checkout again

    Expected result

Checkout page with pre-filled information

Actual result

Javascript error blocking rendering of the page
rules.js:56 Uncaught TypeError: Cannot read property 'length' of undefined

Checkout Format is not valid Ready for Work bug report

Most helpful comment

Solution

just in case if store configuration for customer address is 2 or more street lines then rules.js gives the error. Change store configuration in:
Stores > Configuration > Customer > Customer Configuration > Name and Address Options: Number of Lines in a Street Address make it 1.

All 68 comments

I'm getting the same error.

Same error here.
When the field "street.1" has no content the validation cause an exception. The value.length is undefined.
A workaround is to disable the validation_rules for the customer_eav_attribute "street" in the database.

Error appears on Magento 2.0.7, Magento 2.1-RC2

This is the error from min_text_length and max_text_length. The problem is somehow value is returned as null. So I add null-check logic before accessing its property.

"min_text_length": [
    function (value, params) {
        return !value || (!!value && value.length == 0 || value.length >= +params);
    },
    $.mage.__('Please enter more or equal than {0} symbols.')
],
"max_text_length": [
    function (value, params) {
        return !value || (!!value && value.length <= +params);
    },
    $.mage.__('Please enter less or equal than {0} symbols.')
],

I also faced the same issue, but it is not happening always

Hi Magento team,

Is the fix going to be included into Magento 2.1 stable release? It is blocking logged in customers to place an order.

cc: @antonkril

Thanks,
Max

Hi @asemenenko, @pboisvert

Do you have any updates regarding this issue?

Thanks,
Max

Does anybody have a fix for this please?

any alternative way to fix it? i cant finish developing my gateway because of this

It happens in Magento 2.1.0 as well. I am facing the same issue.

The problem can be better describe like this:

1: When you directly go to checkout page: http://example.com/checkout. Checkout page loads and no error.
2: When you go to cart page first before go to checkout: http://example.com/checkout/cart and then go to checkout page by clicking 'proceed to checkout' button. We get error described in this issue on rules.js.

My debug

I debugged that something happens behind in Local storage of browser in both of the above described scenario.

Upon checking on case 1: My Local storage stores mage-cache-storage with value(beautified Json format) like below:
{ "checkout-data":{ "selectedShippingAddress":null, "shippingAddressFromData":null, "newCustomerShippingAddress":null, "selectedShippingRate":null, "selectedPaymentMethod":null, "selectedBillingAddress":null, "billingAddressFormData":null, "newCustomerBillingAddress":null } }

Upon checking on case 2: My Local storage stores mage-cache-storage with value(beautified Json format) like below:
{"checkout-data":{"selectedShippingAddress":null,"shippingAddressFromData":{"postcode":"2000","country_id":"AU","region":"Victoria","region_code":"Victoria","customer_id":"2","street":{"0":"00 wellington st"},"telephone":"0000000000","city":"melbourne","firstname":"John","lastname":"Smith"},"newCustomerShippingAddress":null,"selectedShippingRate":null,"selectedPaymentMethod":null,"selectedBillingAddress":null,"billingAddressFormData":null,"newCustomerBillingAddress":null}}

Solution

just in case if store configuration for customer address is 2 or more street lines then rules.js gives the error. Change store configuration in:
Stores > Configuration > Customer > Customer Configuration > Name and Address Options: Number of Lines in a Street Address make it 1.

We create internal ticket to solve this issue MAGETWO-47240

@sky4git thanks!!! your solution works well! You saved me a lot of headache

Where is this store configuration? Can't find in 2.1 ee backend.

@rashidio You can find store configuration: STORES->Settings->All Stores

Looking for _Stores > Configuration > Customer > Customer Configuration > Name and Address Options: Number of Lines in a Street Address_
Here's customer settings
image
Stores:
image

Number of Lines in a Street Address changed to 1 works for me! Thanks!

2.1.0 GA, can reproduce.

Can reproduce. Happens if I create a standard shipping address inside the logged in user's profile. You must be logged in for this to reproduce (in 2.1.0).

Very urgent to fix! This stops the user from checking out .

How to reproduce

  1. Create a NEW account in magento install
  2. Login the user.
  3. Add products to cart, and checkout - it will work.
  4. Now we want to get the error described in this ticket. Now go into the user's profile and add standard shipping address / billing address.
  5. Now try adding some product into the cart and try to checkout.
  6. Error will appear inside console and it's impossible to checkout.

How to workaround

Like earlier described here, you can set number of lines in street address to 1.

How the checkout looks

last_opp_den_3 8 2016_kl _16 20 54

Hi @piotrekkaminski @pboisvert

Kindly ask you to update us because it is really blocker for everyone.
We really appreciate your work on resolving this issue.

Thank you in advance,
Max

Fix for this issue was delivered to the develop branch with the commit 7fb8a9c0.

Thank god I got the solution at the right time.
Moving Magento2 to github seems to be one of the best decision made by the team :)

Closed as the issue was fixed.

this is not included in 2.1.1

Also mentioned in https://github.com/magento/magento2/issues/2450 that the setting for 'Number of Lines in a Street Address' is not working and this bug still exists for me.

@PascalBrouwers If you're still experiencing this issue, @TKlement's temporary fix worked for me. I updated set the customer_eav_attribute.validate_rules column to NULL for the street attribute code (you can lookup the ID in the eav_attribute table).

@erikhansen I ended up using that temporary fix. Still I would like to see Magento listening to the setting 'Number of Lines in a Street Address' ;)

Same error showing at adding new product as well. While adding new product, change attribute set and showing same error.

@mcspronko and all. This issue will most probably come in 2.1.3, expected in near term.

There is no 'Number of Lines in a Street Address' option? At least it's not where it was mentioned above: Stores > Configuration > Customer > Customer Configuration > Name and Address Options

@matt-bailey
image

@heldchen Strange, I don't see that. Here's what I see, am I looking in the wrong place?...

configuration settings stores magento admin

what version are you using? probably EE or hosted...

@heldchen 2.1.0

sure, but which edition?

Sorry, EE.

the address settings are configured differently in EE, that's why you don't see the fields.

Ah ok, so does anyone know if there's a way to 'fix' this for EE? At the moment I'm unable to work on styling the checkout.

you can edit the EE Customer Address attributes either in the gui or in the db directly if the gui fails. or request support from magento enterprise.

Ok, so I think I found the setting in EE in Stores > Attributes / Customer Address. However, it won't allow you to set the value to '1'. It says "Valid range 2-20".

screenshot 2016-09-30 19 33 06

Does anyone know any other way of solving this in EE, it's an absolute show-stopper! How are customers supposed to checkout, let alone me be able to style the checkout?...

FYI, my site has a clean DB install from earlier today. There is only one customer set up (me) and only a couple of Simple test products.

I have the same exact problem with 2.1.0 EE .. You can only have a minimum of 2 lines. I could "hack it" but I don't want to risk breaking other stuff! Anyone found a fix for this? Please share if so.

@FerrazzzZ see erikhansen's comment: https://github.com/magento/magento2/issues/4921#issuecomment-247055414

@FerrazzzZ It appears to be fixed in 2.1.2

@Ctucker9233 we still have not done the patch, is it actually fixed in 2.1.2? Has the patch broken anything else so far?

No, issue is still there in 2.1.2. I have changed Address Line to 1 and facing the issue An error occurred on the server. Please try to place the order.

@sanjayjethva @magento-team If we make the street address configuration to 1 then the customer will not be able to login if he already have 2 line in street address because it looks like the system validatation is happening during login and I am getting the below exception.

1 exception(s):
Exception #0 (Magento\Framework\Validator\Exception): "Street Address" cannot contain more than 1 lines.

Exception #0 (Magento\Framework\Validator\Exception): "Street Address" cannot contain more than 1 lines.
#0 ./vendor/magento/module-customer/Model/ResourceModel/Address.php(77): Magento\Customer\Model\ResourceModel\Address->_validate(Object(Magento\Customer\Model\Address))
#1 ./vendor/magento/module-eav/Model/Entity/VersionControl/AbstractEntity.php(90): Magento\Customer\Model\ResourceModel\Address->_beforeSave(Object(Magento\Customer\Model\Address))
#2 ./vendor/magento/framework/Interception/Interceptor.php(74): Magento\Eav\Model\Entity\VersionControl\AbstractEntity->save(Object(Magento\Customer\Model\Address))
#3 ./vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Customer\Model\ResourceModel\Address\Interceptor->___callParent('save', Array)
#4 ./vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'save', Object(Magento\Customer\Model\ResourceModel\Address\Interceptor), Array, 'clean_cache')
#5 ./vendor/magento/framework/App/Cache/FlushCacheByTags.php(60): Magento\Customer\Model\ResourceModel\Address\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Customer\Model\Address))
#6 ./vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\App\Cache\FlushCacheByTags->aroundSave(Object(Magento\Customer\Model\ResourceModel\Address\Interceptor), Object(Closure), Object(Magento\Customer\Model\Address))
#7 ./var/generation/Magento/Customer/Model/ResourceModel/Address/Interceptor.php(39): Magento\Customer\Model\ResourceModel\Address\Interceptor->___callPlugins('save', Array, Array)
#8 ./vendor/magento/framework/Model/AbstractModel.php(631): Magento\Customer\Model\ResourceModel\Address\Interceptor->save(Object(Magento\Customer\Model\Address))
#9 ./vendor/magento/module-customer/Model/ResourceModel/Customer/Relation.php(49): Magento\Framework\Model\AbstractModel->save()
#10 ./vendor/magento/framework/Model/ResourceModel/Db/VersionControl/RelationComposite.php(48): Magento\Customer\Model\ResourceModel\Customer\Relation->processRelation(Object(Magento\Customer\Model\Customer))
#11 ./vendor/magento/module-eav/Model/Entity/VersionControl/AbstractEntity.php(95): Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite->processRelations(Object(Magento\Customer\Model\Customer))
#12 ./vendor/magento/framework/Interception/Interceptor.php(74): Magento\Eav\Model\Entity\VersionControl\AbstractEntity->save(Object(Magento\Customer\Model\Customer))
#13 ./vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Customer\Model\ResourceModel\Customer\Interceptor->___callParent('save', Array)
#14 ./vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'save', Object(Magento\Customer\Model\ResourceModel\Customer\Interceptor), Array, 'clean_cache')
#15 ./vendor/magento/framework/App/Cache/FlushCacheByTags.php(60): Magento\Customer\Model\ResourceModel\Customer\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Customer\Model\Customer))
#16 ./vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\App\Cache\FlushCacheByTags->aroundSave(Object(Magento\Customer\Model\ResourceModel\Customer\Interceptor), Object(Closure), Object(Magento\Customer\Model\Customer))
#17 ./var/generation/Magento/Customer/Model/ResourceModel/Customer/Interceptor.php(26): Magento\Customer\Model\ResourceModel\Customer\Interceptor->___callPlugins('save', Array, Array)
#18 ./vendor/magento/framework/Model/AbstractModel.php(631): Magento\Customer\Model\ResourceModel\Customer\Interceptor->save(Object(Magento\Customer\Model\Customer))
#19 ./vendor/magento/module-customer/Model/ResourceModel/CustomerRepository.php(193): Magento\Framework\Model\AbstractModel->save()
#20 ./vendor/magento/framework/Interception/Interceptor.php(74): Magento\Customer\Model\ResourceModel\CustomerRepository->save(Object(Magento\Customer\Model\Data\Customer), NULL)
#21 ./vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Customer\Model\ResourceModel\CustomerRepository\Interceptor->___callParent('save', Array)
#22 ./vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'save', Object(Magento\Customer\Model\ResourceModel\CustomerRepository\Interceptor), Array, 'update_newslett...')
#23 ./vendor/magento/module-newsletter/Model/Plugin/CustomerPlugin.php(61): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Customer\Model\Data\Customer), NULL)
#24 ./vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Newsletter\Model\Plugin\CustomerPlugin->aroundSave(Object(Magento\Customer\Model\ResourceModel\CustomerRepository\Interceptor), Object(Closure), Object(Magento\Customer\Model\Data\Customer), NULL)
#25 ./vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'save', Object(Magento\Customer\Model\ResourceModel\CustomerRepository\Interceptor), Array, 'transactionWrap...')
#26 ./vendor/magento/module-customer/Model/Plugin/CustomerRepository/TransactionWrapper.php(44): Magento\Customer\Model\ResourceModel\CustomerRepository\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Customer\Model\Data\Customer), NULL)
#27 ./vendor/magento/framework/Interception/Interceptor.php(142): Magento\Customer\Model\Plugin\CustomerRepository\TransactionWrapper->aroundSave(Object(Magento\Customer\Model\ResourceModel\CustomerRepository\Interceptor), Object(Closure), Object(Magento\Customer\Model\Data\Customer))
#28 ./var/generation/Magento/Customer/Model/ResourceModel/CustomerRepository/Interceptor.php(26): Magento\Customer\Model\ResourceModel\CustomerRepository\Interceptor->___callPlugins('save', Array, Array)
#29 ./vendor/magento/module-customer/Model/Authentication.php(120): Magento\Customer\Model\ResourceModel\CustomerRepository\Interceptor->save(Object(Magento\Customer\Model\Data\Customer))
#30 ./vendor/magento/module-customer/Observer/CustomerLoginSuccessObserver.php(41): Magento\Customer\Model\Authentication->unlock('3')
#31 ./vendor/magento/framework/Event/Invoker/InvokerDefault.php(73): Magento\Customer\Observer\CustomerLoginSuccessObserver->execute(Object(Magento\Framework\Event\Observer))
#32 ./vendor/magento/framework/Event/Invoker/InvokerDefault.php(61): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Magento\Customer\Observer\CustomerLoginSuccessObserver), Object(Magento\Framework\Event\Observer))
#33 ./vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))
#34 ./var/generation/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch('customer_custom...', Array)
#35 ./vendor/magento/module-customer/Model/AccountManagement.php(477): Magento\Framework\Event\Manager\Proxy->dispatch('customer_custom...', Array)
#36 ./vendor/magento/module-customer/Controller/Account/LoginPost.php(147): Magento\Customer\Model\AccountManagement->authenticate('******', '******')
#37 ./vendor/magento/framework/App/Action/Action.php(102): Magento\Customer\Controller\Account\LoginPost->execute()
#38 ./vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#39 ./vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Customer\Controller\Account\LoginPost\Interceptor->___callParent('dispatch', Array)
#40 ./vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'dispatch', Object(Magento\Customer\Controller\Account\LoginPost\Interceptor), Array, 'contextPlugin')
#41 ./vendor/magento/module-store/App/Action/Plugin/Context.php(106): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#42 ./vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Store\App\Action\Plugin\Context->aroundDispatch(Object(Magento\Customer\Controller\Account\LoginPost\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#43 ./vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'dispatch', Object(Magento\Customer\Controller\Account\LoginPost\Interceptor), Array, 'customer-app-ac...')
#44 ./vendor/magento/module-customer/Model/App/Action/ContextPlugin.php(61): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#45 ./vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Customer\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Customer\Controller\Account\LoginPost\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#46 ./vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'dispatch', Object(Magento\Customer\Controller\Account\LoginPost\Interceptor), Array, 'storeCheck')
#47 ./vendor/magento/module-store/App/Action/Plugin/StoreCheck.php(44): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#48 ./vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Store\App\Action\Plugin\StoreCheck->aroundDispatch(Object(Magento\Customer\Controller\Account\LoginPost\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#49 ./vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'dispatch', Object(Magento\Customer\Controller\Account\LoginPost\Interceptor), Array, 'customer_accoun...')
#50 ./vendor/magento/module-customer/Controller/Plugin/Account.php(60): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#51 ./vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Customer\Controller\Plugin\Account->aroundDispatch(Object(Magento\Customer\Controller\Account\LoginPost\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#52 ./vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'dispatch', Object(Magento\Customer\Controller\Account\LoginPost\Interceptor), Array, 'weee-app-action...')
#53 ./vendor/magento/module-weee/Model/App/Action/ContextPlugin.php(112): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#54 ./vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Weee\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Customer\Controller\Account\LoginPost\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#55 ./vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'dispatch', Object(Magento\Customer\Controller\Account\LoginPost\Interceptor), Array, 'tax-app-action-...')
#56 ./vendor/magento/module-tax/Model/App/Action/ContextPlugin.php(91): Magento\Customer\Controller\Account\LoginPost\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#57 ./vendor/magento/framework/Interception/Interceptor.php(142): Magento\Tax\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Customer\Controller\Account\LoginPost\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#58 ./var/generation/Magento/Customer/Controller/Account/LoginPost/Interceptor.php(26): Magento\Customer\Controller\Account\LoginPost\Interceptor->___callPlugins('dispatch', Array, Array)
#59 ./vendor/magento/framework/App/FrontController.php(55): Magento\Customer\Controller\Account\LoginPost\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#60 ./vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#61 ./vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#62 ./vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'requestPreproce...')
#63 ./vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#64 ./vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#65 ./vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#66 ./vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#67 ./vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#68 ./vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#69 ./vendor/magento/module-page-cache/Model/App/FrontController/VarnishPlugin.php(55): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#70 ./vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#71 ./vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#72 ./vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#73 ./vendor/magento/framework/Interception/Interceptor.php(142): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#74 ./var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#75 ./vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#76 ./vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#77 ./pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#78 {main}

@FerrazzzZ I apologize. I believe I commented on the wrong issue.

issue still available in 2.1.2 and will be fixed with changing address lines to 1 !

I couldn't set the address lines to 1 because it is multi-line attribute and its minimum value is 2.
One way to fix it is to override the
getMultilineFieldConfig
method in
Magento\Checkout\Block\Checkout\AttributeMerger
class and change the line 274 so that it looks like this

'validation' => $isFirstLine ? array_merge( ['required-entry' => (bool)$attributeConfig['required']], $attributeConfig['validation'] ) : ['required-entry' => false]

In this case the require-entry is set on the first line of the street and required-entry is set to false on the second line of the street.

Seeing this issue too in 2.1.2. Just tested @liiskmaa's suggestion, and it works 馃憤

@piotrekkaminski when is 2.1.3 due? This is stopping me developing a payment module
@liiskmaa didn't work for me - EE 2.1.2
@matt-bailey I hacked it to 1.. still doesn't work for me in EE

I'm able to reprocedure this on Magento 2.1.0 EE, I can't find configuration like @sky4git solution. So I have to move to @liiskmaa solution.

I think at this moment, that is the only way to fix this issue in Magento 2.1.x EE

Magento\Checkout\Block\Checkout\AttributeMerger

Change

$attributeConfig['validation']

to

['required-entry' => false]

Clearing local storage worked for me.

What is the status of a fix for this issue? This is a critical error preventing people from checking out. I'm disappointed that this issue has been known for so long and a proper Magento fix is yet to be released. I need a better solution than changing the number of lines in the street to 1, this is not an acceptable solution as many of our users have addresses with multiple lines.

I need and update on this as soon as possible.

Here's a solution which builds on that provided by @liiskmaa, but doesn't require modification to the core code.

Create a new plugin in a custom module. I've named it AttributeMerger.

class AttributeMerger
{
    public function afterMerge(
        \Magento\Checkout\Block\Checkout\AttributeMerger $subject,
        array $fields
    ) {
        if (!isset($fields['street'])) {
            return $fields;
        }
        $lines = $fields['street']['children'];
        for ($lineIndex = 0; $lineIndex < count($lines); $lineIndex++) {
            if ($lineIndex !== 0) {
                $lines[$lineIndex]['validation'] = ['required-entry' => false];
            }
        }
        $fields['street']['children'] = $lines;
        return $fields;
    }
}

Then define the plugin in your di.xml.

<type name="Magento\Checkout\Block\Checkout\AttributeMerger">
    <plugin name="checkout_attribute_merger_plugin" type="Company\Module\Plugin\AttributeMerger" />
</type>

seems to be fixed in CE 2.1.3

@sma09sjb, are you running CE 2.1.3?

I just tested it, and it seems fixed in 2.1.3

@erfanimani i'm running CE 2.1.2, I will try an upgrade.

@erfanimani just upgraded but still have the same error:

"Street Address" cannot contain more than 1 lines.

Not sure how relevant this is, but might be a line of enquiry to track down the issue for Magento .

While changing the street address lines to 1 in the config fixed the issue for submitting the form, for existing customers with 2 address lines this made them not visible in their account and the backend.

Through some testing I've found that if you enter exactly the same text in line 2 as you do in line 1 the form will submit successfully, it looks as though the validation is looking to compare the 2 fields rather than validate them individually?

If someone else experiencing these issues can also test and confirm if this is the case then perhaps Magento developers can look into this.

@sky4git you're a life saver!

Just an update, this now happening on 2.1.8

Sky4git's solution still works:

This is even worse. There is no explanation what so ever when you want to add customers by code.

I clearly give just 1 line

$contactaddressstreet = $contactaddress['AddressLine1'] . ' ' . $contactaddress['AddressLine2'] . ' ' . $contactaddress['AddressLine3'];

`........->setStreet(array($contactaddressstreet))`

And my whole ssh console is full with

Street Address" cannot contain more than 1 lines.

When i go and take a look at the setstreet function :

/**
     * Set street
     *
     * @param string[] $street
     * @return $this
     */
    public function setStreet(array $street);

This provides no information at all. It expect an array but what kind of array? How would you define your array? Do i need to assume that i do not need to provide keys like 'street1' ?

magento 2.1.8

Edit

This has been fixed by just replacing all extra spaces with a single space like this
$contactaddressstreet = trim(preg_replace('/\s\s+/', ' ',$contactaddress['AddressLine1'])) . ' ' . trim(preg_replace('/\s\s+/', ' ',$contactaddress['AddressLine2'])) . ' ' . trim(preg_replace('/\s\s+/', ' ',$contactaddress['AddressLine3']));

(i know its a messy code , i will make a function out of that.) . I will leave this here for future reference. Maybe just always delete extra spaces on setStreet? Unless there is a reason to not add that.

Still not sure why getStreet needs the array when appearently 2 spaces or \n moves everything to the second line.

@veloraven
This bug is very hard to reproduce. Sorry, I can't provide step by step.
https://github.com/magento/magento2/commit/7fb8a9c0ede398c661f001ac22fa4fb7dc642b2b
doesn't look like the correct fix, it hides the cause.

By default, this issue is caused by one of the API request on the cart page.
Most likely is http://example.com/rest/default/V1/carts/mine/estimate-shipping-methods
Usually it shows if you add a simple link on the checkout page back to cart page.
You click fast on the link and land on cart page and than click fast to Proceed to Checkout.
It defaults the street address object in local storage to an empty array: [] (or something else ?).
Knockout templates on checkout page, shipping address expect street to be 2 input elements.
The html elements/street array in local storage are not there and validation fails with Javascript Error, checkout is blank, no sale.
Basically Magento team needs to initialize correctly street address in all cases: an empty array with 1, 2 or more lines depending on configuration. Or fix the case in checkout JS.
As far as I looked in the Magento 2 PHP code, the street is a special case with values stored in an array and is not a single string/int/object value.

To do a workaround, copy and edit this file in your theme:
magento/module-checkout/view/frontend/web/js/model/address-converter.js

In function formAddressDataToQuoteAddress after:

addressData.street = this.objectToArray(addressData.street);
if addressData.street exists and it.s .length is 0,
than init addressData.street with empty array [].
And than add to street array 2 empty strings (.push("");).
If you have 3 street lines in the address than push 3 times empty string.
The number must match exactly how many street addresses lines you have in customer address attribute "street" > "multiline_count" column, table customer_eav_attribute.
You can eventually read this number from a window.lorem.ipsum variable read from config moduels and set in a template (after body starts: block/template).

Flush cache, deploy static content and when you visit checkout page make sure in browser that address-converter.js has your changes. Since local storage is already set and if the issue is still not fixed, you can delete 'browser cache' (local storage included) and try to reproduce the bug again. It should not show again.
This checkout white page bug can happen in other cases. Can happen when POST to Magento 2 API requests in cart and checkout page fail for any other reason (like a PHP fatal error syntax error or bugs in third party code).

It doesn't work if you increase or decrease the street number of lines without this fix.

Also make sure you have same number in Admin > Stores > Configuration > Customer > Customer Configuration > Name and Address Options > Number of Lines in Street Address
is exactly the same with the number in table customer_eav_attribute, column multiline_count of attribute street (customer_address entity).

The problem still exist if you turn on js bundling (EE ver. 2.2.5). Does anyone have solution which works with turned on js bundling?

Almost 4 years after the initial report of this bug and its still here...

@operator888
If you are experiencing the original issue in this task you can fix it in file (or create a mixin in store's theme):
vendor/magento/module-checkout/view/frontend/web/js/model/address-converter.js, function formAddressDataToQuoteAddress:

           if (mageUtils.isObject(addressData.street)) {
                addressData.street = this.objectToArray(addressData.street);

                // Add array with empty items [0 => "", ..] instead of empty array []
                var streetMultilineCount = (window.checkoutConfig.someNamespace &&
                    window.checkoutConfig.someNamespace.streetMultilineCount ?
                    window.checkoutConfig.someNamespace.streetMultilineCount : false);
                if (streetMultilineCount !== false) {
                    if (addressData && addressData.street && addressData.street.length <= 0) {
                        addressData.street = [];
                        for (var i = 1; i <= streetMultilineCount; i++) {
                            addressData.street.push('');
                        }
                    }
                }
            }

Where window.checkoutConfig.someNamespace.streetMultilineCount should contain the number of street attribute lines. This is configured in admin and saved in the customer_eav_attribute.
You can bring this value doing a config provider, similar to the ones declared in:
vendor/magento/module-checkout/etc/frontend/di.xml

    <type name="Magento\Checkout\Model\CompositeConfigProvider">
        <arguments>
            <argument name="configProviders" xsi:type="array">
                <item name="checkout_default_config_provider" xsi:type="object">Magento\Checkout\Model\DefaultConfigProvider</item>
                <item name="checkout_summary_config_provider" xsi:type="object">Magento\Checkout\Model\Cart\CheckoutSummaryConfigProvider</item>
            </argument>
        </arguments>
    </type>

The value of street address is corrupted. addressData is an array. It should contain the exact number of items as lines configured in street address attribute.
undefined value ends up on the street address lines components from the end.
Street address components are injected from here:
vendor/magento/module-checkout/Block/Checkout/AttributeMerger.php, function getMultilineFieldConfig.
You can see them in shippingAddress (and paymentAddress) in checkout html page source,


<script type="text/x-magento-init">
--
聽 | {
聽 | "#checkout": {
      ...

Magento devs did an workaround for this. Apparently it's not working all the time.
They did a global fix on rules.js / validation.js.
Where any error related to 'undefined' value triggered by a component's validation is suppressed.
The fix buries the bug further.
I guess it's because the bug is hard to reproduce.
The actual fix is about normalization of a value with default values which Magento was never great at it, especially with default values on eav attributes.
The bug may come further from PHP side of checkout. Like the street address should always contain an array with same number of street address lines, even if a line is empty. In most cases it does this. But in some cases when you click on back to cart link (custom implementation) from checkout page, a race condition happens and it corrupts street value or just some PHP bug/non feature somewhere.

Was this page helpful?
0 / 5 - 0 ratings