Skip to content
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

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

Closed
PetraSwed opened this issue Jun 7, 2016 · 70 comments
Assignees
Labels
bug report Component: Checkout Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@PetraSwed
Copy link

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

@willstorm
Copy link

I'm getting the same error.

@TKlement
Copy link

TKlement commented Jun 14, 2016

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.

@mcspronko
Copy link
Contributor

Error appears on Magento 2.0.7, Magento 2.1-RC2

@komsitr
Copy link
Contributor

komsitr commented Jun 21, 2016

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.')
],

@charleskj
Copy link

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

@mcspronko
Copy link
Contributor

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

@mcspronko
Copy link
Contributor

Hi @asemenenko, @pboisvert

Do you have any updates regarding this issue?

Thanks,
Max

@gavinlimely
Copy link

Does anybody have a fix for this please?

@refaelgold
Copy link

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

@sky4git
Copy link

sky4git commented Jul 19, 2016

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

@sky4git
Copy link

sky4git commented Jul 20, 2016

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}}

@sky4git
Copy link

sky4git commented Jul 20, 2016

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.

@irenelagno
Copy link
Contributor

We create internal ticket to solve this issue MAGETWO-47240

@mauromm
Copy link

mauromm commented Jul 20, 2016

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

@rashidio
Copy link

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

@irenelagno
Copy link
Contributor

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

@rashidio
Copy link

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

@milkolori
Copy link

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

@peec
Copy link

peec commented Aug 4, 2016

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

@mcspronko
Copy link
Contributor

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

@irenelagno
Copy link
Contributor

irenelagno commented Aug 5, 2016

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

@MagePsycho
Copy link
Contributor

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 :)

@veloraven veloraven added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report labels Aug 18, 2016
@senthilengg
Copy link

senthilengg commented Oct 18, 2016

@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}

@Ctucker9233
Copy link

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

@sIiiS
Copy link
Contributor

sIiiS commented Oct 26, 2016

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

@liiskmaa
Copy link
Contributor

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.

@ashsmith
Copy link

ashsmith commented Nov 1, 2016

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

@csdougliss
Copy link
Contributor

csdougliss commented Nov 2, 2016

@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

@nntoan
Copy link
Contributor

nntoan commented Nov 28, 2016

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]

@jreinke
Copy link

jreinke commented Dec 5, 2016

Clearing local storage worked for me.

@sma09sjb
Copy link

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.

@qubaji
Copy link

qubaji commented Dec 22, 2016

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>

@bh-ref
Copy link
Contributor

bh-ref commented Dec 22, 2016

seems to be fixed in CE 2.1.3

@erfanimani
Copy link
Contributor

erfanimani commented Dec 23, 2016

@sma09sjb, are you running CE 2.1.3?

I just tested it, and it seems fixed in 2.1.3

@sma09sjb
Copy link

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

@scher200
Copy link

scher200 commented Jan 5, 2017

@erfanimani just upgraded but still have the same error:

"Street Address" cannot contain more than 1 lines.

@Joe-Whitehead
Copy link

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.

@cuiyang000
Copy link

@sky4git you're a life saver!

@IndigoLV
Copy link

Just an update, this now happening on 2.1.8

Sky4git's solution still works:

@versdivers
Copy link

versdivers commented Sep 21, 2017

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.

@magento-engcom-team magento-engcom-team added the Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed label Sep 21, 2017
@daniel-ifrim
Copy link

daniel-ifrim commented Oct 7, 2017

@veloraven
This bug is very hard to reproduce. Sorry, I can't provide step by step.
7fb8a9c
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).

@kaushik-kumar-roy
Copy link

@tymur-yunusov
Copy link

tymur-yunusov commented Feb 19, 2019

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?

magento-engcom-team pushed a commit that referenced this issue Oct 25, 2019
@operator888
Copy link
Member

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

@daniel-ifrim
Copy link

daniel-ifrim commented Feb 26, 2020

@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.

@GearedByDesign
Copy link

This is still a problem on Magento 2.4.2

If you check out as a guest then it works but as soon as you log in and checkout you get the validation error.

I have used the solution that @komsitr suggested and implemented it for both min and max fields as you will get the min error after you fix the max error.

You can find this in the vendor\magenot\module-ui\view\base\web\lib\validation\rules.js

and edit lines

line 63 (Min Rule) and line 69 (Max Rule)

Change to : return !value || (!!value && value.length <= +params);

Worked for me!
@komsitr thanks for the fix

@GearedByDesign
Copy link

This is still a problem on Magento 2.4.2

If you check out as a guest then it works but as soon as you log in and checkout you get the validation error.

I have used the solution that @komsitr suggested and implemented it for both min and max fields as you will get the min error after you fix the max error.

You can find this in the vendor\magenot\module-ui\view\base\web\lib\validation\rules.js

and edit lines

line 63 (Min Rule) and line 69 (Max Rule)

Change to : return !value || (!!value && value.length <= +params);

Worked for me!
@komsitr thanks for the fix

Do not use this solution! it looked like it worked at first but it creates new issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Checkout Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests