magento2-page-builder icon indicating copy to clipboard operation
magento2-page-builder copied to clipboard

Validator rule required-entry crashes when value is null

Open amenk opened this issue 3 years ago • 13 comments

Summary (*)

We upgraded to Magento 2.4.3 and cannot load the product editor anymore in the backend.

There is a javascript error raised:

Uncaught TypeError: Cannot read properties of null (reading 'padding')
    at Object.eval [as handler] (eval at require.load (ffa15b10614cc201590659b91698e94c.min.js:178), <anonymous>:19:182)
    at validate (eval at require.load (ffa15b10614cc201590659b91698e94c.min.js:178), <anonymous>:5:61)
    at eval (eval at require.load (ffa15b10614cc201590659b91698e94c.min.js:178), <anonymous>:8:217)
    at Function._.every._.all (eval at require.load (ffa15b10614cc201590659b91698e94c.min.js:178), <anonymous>:16:571)
    at validator (eval at require.load (ffa15b10614cc201590659b91698e94c.min.js:178), <anonymous>:8:112)
    at UiClass.validate (eval at require.load (ffa15b10614cc201590659b91698e94c.min.js:178), <anonymous>:9:678)
    at setNested (eval at require.load (ffa15b10614cc201590659b91698e94c.min.js:178), <anonymous>:5:50)
    at Object.nested (eval at require.load (ffa15b10614cc201590659b91698e94c.min.js:178), <anonymous>:11:127)
    at UiClass.set (eval at require.load (ffa15b10614cc201590659b91698e94c.min.js:178), <anonymous>:12:318)
    at updateValue (eval at require.load (ffa15b10614cc201590659b91698e94c.min.js:178), <anonymous>:11:80)

We tracked that down to the following code

https://github.com/magento/magento2-page-builder/blob/8ed420dd9b8f79472e8266d46611a93e40cb7fe0/app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element/validator-rules-mixin.js#L237

It seems to be a valid case, that value is null. In this case, the script still tried to read .padding.

Is that intended?

Also I do not understand why the validator required-entry is registered - isn't that already a commonly used validator which also should work on null values?

Proposed solution

if (typeof value === 'object' && value !== null && !!(value.padding || value.margin)) {

amenk avatar Nov 24 '21 14:11 amenk

Hi @amenk. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this


m2-assistant[bot] avatar Nov 24 '21 14:11 m2-assistant[bot]

Facing this issue on Magento 2.4.5-p1 as well, the value is somehow null, and null is an object according to javascript. As suggested by @amenk, adding a value !== null inside the if would solve the issue on hand.

However the issue is not always occuring, but I still believe that a fix would help here.

Might also be related to #36863

MrBlueEyez avatar May 25 '23 07:05 MrBlueEyez

If it may help, I found the field that caused the problem by placing a breakpoint here: image Just unwrap the this UiClass and all the useful data will be there. In my case it was due to a third party module that since got updated.

TheBadong avatar Sep 08 '23 08:09 TheBadong

I am getting this issue when I open the attribute tab on product edit page in admin and trying to make changes and save the product. getting below error in console and unable to save the product validator-rules-mixin.js:237 Uncaught TypeError: Cannot read properties of null (reading 'padding') at Object.handler (validator-rules-mixin.js:237:59) at validate (validator.js:44:24) at validator.js:84:30 at Function.every (underscore.js:1408:18) at validator (validator.js:82:15) at UiClass.validate (abstract.js:407:26) at setNested (objects.js:44:25) at Object.nested (objects.js:118:20) at UiClass.set (element.js:305:19) at updateValue (links.js:80:19)

I am using magento 2.4.4-p1 Any one having update to resolve this.

hemendrametawolf avatar Jul 04 '24 11:07 hemendrametawolf

@hemendrametawolf are you able to reproduce this on a clean instance reliably?

amenk avatar Jul 04 '24 13:07 amenk

@hemendrametawolf are you able to reproduce this on a clean instance reliably?

No let me check that.

hemendrametawolf avatar Jul 04 '24 13:07 hemendrametawolf

@magento give me 2.4.4-p1 instance

hemendrametawolf avatar Jul 04 '24 13:07 hemendrametawolf

Hi @hemendrametawolf. Thank you for your request. I'm working on Magento instance for you.

Hi @hemendrametawolf, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

@magento give me 2.4.4 instance

hemendrametawolf avatar Jul 04 '24 13:07 hemendrametawolf

Hi @hemendrametawolf. Thank you for your request. I'm working on Magento instance for you.

Hi @hemendrametawolf, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

This issue has been addressed in the latest release.

NitrogenUA avatar Jul 08 '24 07:07 NitrogenUA