justpy-org / justpy

An object oriented high-level Python Web Framework that requires no frontend programming
https://justpy.io
Apache License 2.0
1.22k stars 96 forks source link

AG Grid: "Cannot convert undefined or null to object" #384

Closed falkoschindler closed 2 years ago

falkoschindler commented 2 years ago

Under certain circumstances - which I can't manage to reproduce in a minimum example - I get a JavaScript error when updating an AG Grid:

TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at a.evaluate_formatters (measure:1762:51)
    at a.evaluate_formatters (measure:1766:26)
    at a.evaluate_formatters (measure:1766:26)
    at a.evaluate_formatters (measure:1766:26)
    at a.grid_change (measure:1782:18)
    at a.updated (measure:1891:18)
    at He (vue.js:2:11397)
    at Yt (vue.js:2:25339)
    at vue.js:2:26012

I suspect it it caused by the condition if (typeof def == "object") in aggrid.js, which is true for null. But Object.entries(def) fails for def == null. So it should be if (typeof def == "object" && def !== null).

A very similar line is in chartjp.js.

WolfgangFahl commented 2 years ago

@falkoschindler this would be a good example where tests might help. I have the behavior if None values are part of the data to be sent to aggrid and therefore i keep avoing None values for the time being.

falkoschindler commented 2 years ago

@WolfgangFahl I agree that tests would help. But as mentioned above, I didn't manage to reproduce the issue in a minimum example. The problem occurred in a larger user interface and I just noticed that line in aggrid.js. When handling the null case, the problem was gone.

I have the behavior if None values are part of the data to be sent to aggrid and therefore i keep avoing None values for the time being.

Sorry, I don't get what you are saying.

~Since I don't seem to be able to commit to this repository directly, I created PR https://github.com/elimintz/justpy/pull/450 fixing this line.~ Nevermind, I managed to commit the change.