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

TypeError on null fields #42

Closed
edgrasso opened this issue Jul 29, 2019 · 6 comments
Closed

TypeError on null fields #42

edgrasso opened this issue Jul 29, 2019 · 6 comments
Labels
P: High S: approved The issue has been validated. T: bug Functionality that does not work as intended/expected

Comments

@edgrasso
Copy link

When the template contains a Placeholder with nested properties, everything works fine if the path described by the placeholder exists or if one (or more) of the listed properties does not exist at all, but a TypeError occurs if one of the properties is null.

As an instance, considering the placeholder {d.A.B.C}

{ "A" : { "B" : { "C" : 1 } } } => Ok
{ "A" : { } } => Ok
{ "A" : { "B" : null }} => TypeError: Cannot read property 'C' of null

Mainly, the issue was due to the use of the operator "!==" to perform the due checks (null !== undefined => true).

Moreover a null/undefined check is missing at all in "getBuilderFunction" method, in the section responsible for the composition of the code related to arrays initialization (rows 474 and 477).

@rkaw92
Copy link
Contributor

rkaw92 commented Jul 29, 2019

Hi, fellow user here. We've developed a branch that adds dynamic key support, and incidentally, also tackles this issue: greatcare@e2a143b

Can you try that and tell us if it solves the problem for you?

@edgrasso
Copy link
Author

Hi, thanks for your reply.
Your branch partially solves the issue but, as I stated in the last two lines of my previous post, there is a null-check that is missing at all in the code section related to arrays initialization so, if your template is referencing an array and it does not exist in the bound model, the library throws a TypeError.

@steevepay steevepay added P: High S: on hold The issue is on hold until further notice T: bug Functionality that does not work as intended/expected labels Oct 8, 2019
@steevepay
Copy link
Member

Hi @edgrasso,

First, thanks for the bug report and we will fix this.
Meanwhile, feel free to fork the project and contribute :)

@steevepay steevepay added S: approved The issue has been validated. and removed S: on hold The issue is on hold until further notice labels Oct 9, 2019
@adgelbfish
Copy link

any update on this?

@steevepay
Copy link
Member

Hi @adgelbfish, here is an update with Carbone: #9 (comment). We will focus on this issue after shipping the new version.

@steevepay
Copy link
Member

It has been fixed in the lastest release v2.0.0, I close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P: High S: approved The issue has been validated. T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

No branches or pull requests

4 participants