trailheadapps / apex-recipes

A library of concise, meaningful examples of Apex code for common use cases following best practices.
https://developer.salesforce.com
Creative Commons Zero v1.0 Universal
938 stars 449 forks source link

Attempt to de-reference a null object #70

Closed Josecjr closed 3 years ago

Josecjr commented 3 years ago

When I try to access the App I getting this error:

image

apex-07L2900000OGVNEEA5.log

github-actions[bot] commented 3 years ago

Welcome! 👋

Thank you for posting this issue. 🙇🏼‍♂️ We will come back to you latest within the next 48h (working days). Stay tuned!

codefriar commented 3 years ago

@Josecjr - sorry to hear you're having issues.

Can you tell me how you installed and what kind of environment? was it a brand new scratch org ?

Josecjr commented 3 years ago

I just used the link in the readme. It is a sandbox.

Thanks! José Costa Junior

Em qui., 21 de jan. de 2021 às 14:17, Kevin Poorman < notifications@github.com> escreveu:

@Josecjr https://github.com/Josecjr - sorry to hear you're having issues.

Can you tell me how you installed and what kind of environment? was it a brand new scratch org ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/trailheadapps/apex-recipes/issues/70#issuecomment-764875771, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEF5NO47Q26THSXXVFDMIITS3B4TDANCNFSM4WHXXIZQ .

codefriar commented 3 years ago

is there anything else in the sandbox? I'm struggling to duplicate this... have you followed the other instructions aobut perm sets etc?

codefriar commented 3 years ago

Closing as I can't duplicate.

ajiteshps commented 1 year ago

Hey @codefriar - I resolved the issue in my org with below solution (others might get benefit from it)

The issue in my code was at line number 71 groupName = groupName.trim() -> Previously groupName = groupName -> Changed to image

I debugged the groupToListOfNames map and saw one of the entries is coming as null and performing trim on null is causing the issue.

Here is the lightning page output, here we can see the first tree value as blank

image

Let me know if that helps

docbill commented 1 year ago

That looks like a nonsense change, assigning a variable to itself... Instead of adding the appropriate null check.

On Wed, May 3, 2023 at 2:13 PM ajiteshps @.***> wrote:

Hey @codefriar https://github.com/codefriar - I resolved the issue in my org with below solution (others might get benefit from it)

The issue in my code was at line number 71 groupName = groupName.trim() -> Previously groupName = groupName -> Changed to [image: image] https://user-images.githubusercontent.com/42802482/236006400-f32fb27b-cb64-48fd-a5d9-7ca736ed66a3.png

I debugged the groupToListOfNames map and saw one of the entries is coming as null and performing trim on null is causing the issue.

Here is the lightning page output, here we can see the first tree value as blank [image: image] https://user-images.githubusercontent.com/42802482/236006952-7f90497e-332b-49cc-886a-2aca5c6fb397.png

Let me know if that helps

— Reply to this email directly, view it on GitHub https://github.com/trailheadapps/apex-recipes/issues/70#issuecomment-1533495625, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYFYWBRXFYGVZ7Q7I5Y7W3XEKN5HANCNFSM4WHXXIZQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

Bill C Riemers, PhD, CSM, CSD, A-CSD, SALESFORCE CPD I, SALESFORCE CDL&DA

Senior Principal Software Engineer

Red Hat Canada Ltd https://www.redhat.com/

Enterprise Sales + Services (ESSA) https://red.ht/sighttps://patents.justia.com/inventor/bill-c-riemers

ajiteshps commented 1 year ago

Hey Bill,

My point was that even if we remove line 71 groupName = groupName.trim(); it would work, I kept it there to show the difference.

In summary, the issue is that we are trimming null values.

On Thu, May 4, 2023 at 1:05 AM Bill C Riemers @.***> wrote:

That looks like a nonsense change, assigning a variable to itself... Instead of adding the appropriate null check.

On Wed, May 3, 2023 at 2:13 PM ajiteshps @.***> wrote:

Hey @codefriar https://github.com/codefriar - I resolved the issue in my org with below solution (others might get benefit from it)

The issue in my code was at line number 71 groupName = groupName.trim() -> Previously groupName = groupName -> Changed to [image: image] < https://user-images.githubusercontent.com/42802482/236006400-f32fb27b-cb64-48fd-a5d9-7ca736ed66a3.png

I debugged the groupToListOfNames map and saw one of the entries is coming as null and performing trim on null is causing the issue.

Here is the lightning page output, here we can see the first tree value as blank [image: image] < https://user-images.githubusercontent.com/42802482/236006952-7f90497e-332b-49cc-886a-2aca5c6fb397.png

Let me know if that helps

— Reply to this email directly, view it on GitHub < https://github.com/trailheadapps/apex-recipes/issues/70#issuecomment-1533495625 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAYFYWBRXFYGVZ7Q7I5Y7W3XEKN5HANCNFSM4WHXXIZQ

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

Bill C Riemers, PhD, CSM, CSD, A-CSD, SALESFORCE CPD I, SALESFORCE CDL&DA

Senior Principal Software Engineer

Red Hat Canada Ltd https://www.redhat.com/

Enterprise Sales + Services (ESSA) https://red.ht/sighttps://patents.justia.com/inventor/bill-c-riemers

— Reply to this email directly, view it on GitHub https://github.com/trailheadapps/apex-recipes/issues/70#issuecomment-1533607054, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKGR2MSC6WV6UPAYSVADAATXEKXO5ANCNFSM4WHXXIZQ . You are receiving this because you commented.Message ID: @.***>

docbill commented 1 year ago

Ideally this can be solved by using a safe navigation operator, instead of just ".".

https://en.wikipedia.org/wiki/Safe_navigation_operator

On Thu, May 4, 2023 at 12:00 AM ajiteshps @.***> wrote:

Hey Bill,

My point was that even if we remove line 71 groupName = groupName.trim(); it would work, I kept it there to show the difference.

In summary, the issue is that we are trimming null values.

On Thu, May 4, 2023 at 1:05 AM Bill C Riemers @.***> wrote:

That looks like a nonsense change, assigning a variable to itself... Instead of adding the appropriate null check.

On Wed, May 3, 2023 at 2:13 PM ajiteshps @.***> wrote:

Hey @codefriar https://github.com/codefriar - I resolved the issue in my org with below solution (others might get benefit from it)

The issue in my code was at line number 71 groupName = groupName.trim() -> Previously groupName = groupName -> Changed to [image: image] <

https://user-images.githubusercontent.com/42802482/236006400-f32fb27b-cb64-48fd-a5d9-7ca736ed66a3.png

I debugged the groupToListOfNames map and saw one of the entries is coming as null and performing trim on null is causing the issue.

Here is the lightning page output, here we can see the first tree value as blank [image: image] <

https://user-images.githubusercontent.com/42802482/236006952-7f90497e-332b-49cc-886a-2aca5c6fb397.png

Let me know if that helps

— Reply to this email directly, view it on GitHub <

https://github.com/trailheadapps/apex-recipes/issues/70#issuecomment-1533495625

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AAYFYWBRXFYGVZ7Q7I5Y7W3XEKN5HANCNFSM4WHXXIZQ

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

Bill C Riemers, PhD, CSM, CSD, A-CSD, SALESFORCE CPD I, SALESFORCE CDL&DA

Senior Principal Software Engineer

Red Hat Canada Ltd https://www.redhat.com/

Enterprise Sales + Services (ESSA) https://red.ht/sighttps://patents.justia.com/inventor/bill-c-riemers

— Reply to this email directly, view it on GitHub < https://github.com/trailheadapps/apex-recipes/issues/70#issuecomment-1533607054 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AKGR2MSC6WV6UPAYSVADAATXEKXO5ANCNFSM4WHXXIZQ

. You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/trailheadapps/apex-recipes/issues/70#issuecomment-1534065087, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYFYWCLA4COXA6234GZH2TXEMSVVANCNFSM4WHXXIZQ . You are receiving this because you commented.Message ID: @.***>

--

Bill C Riemers, PhD, CSM, CSD, A-CSD, SALESFORCE CPD I, SALESFORCE CDL&DA

Senior Principal Software Engineer

Red Hat Canada Ltd https://www.redhat.com/

Enterprise Sales + Services (ESSA) https://red.ht/sighttps://patents.justia.com/inventor/bill-c-riemers

ajiteshps commented 1 year ago

That is correct.

Also, I would say we need a better query to identify the classes used in the apex recipes package because I think at the moment it is using the @group in the class body to identify the classes related to the package.

I have comment helper extension in vs code which adds @group to every class so it is picking all the non-apex receipe related classes and therefore we are seeing this null.

image

FYI @codefriar

docbill commented 1 year ago

Don't get me started. ApexDox is a fairly stable standard. It really bugs me that people don't follow it, and just arbitrarily invent non-existant attributes, and use the existing ones incorrectly. How does one expect the @group to parse if they arbitrarily add in colons for no apparent reason?

On Thu, May 4, 2023 at 2:20 PM ajiteshps @.***> wrote:

That is correct.

Also, I would say we need a better query to identify the classes used in the apex recipes package because I think at the moment it is using the @.**' text in the class body to identify the classes related to the package. I have comment helper extension vs code which adds @group to every class so it is picking all the non-apex receipe related classes and therefore we are seeing this null.

[image: image.png]

On Thu, May 4, 2023 at 7:37 PM Bill C Riemers @.***> wrote:

Ideally this can be solved by using a safe navigation operator, instead of just ".".

https://en.wikipedia.org/wiki/Safe_navigation_operator

On Thu, May 4, 2023 at 12:00 AM ajiteshps @.***> wrote:

Hey Bill,

My point was that even if we remove line 71 groupName = groupName.trim(); it would work, I kept it there to show the difference.

In summary, the issue is that we are trimming null values.

On Thu, May 4, 2023 at 1:05 AM Bill C Riemers @.***> wrote:

That looks like a nonsense change, assigning a variable to itself... Instead of adding the appropriate null check.

On Wed, May 3, 2023 at 2:13 PM ajiteshps @.***> wrote:

Hey @codefriar https://github.com/codefriar - I resolved the issue in my org with below solution (others might get benefit from it)

The issue in my code was at line number 71 groupName = groupName.trim() -> Previously groupName = groupName -> Changed to [image: image] <

https://user-images.githubusercontent.com/42802482/236006400-f32fb27b-cb64-48fd-a5d9-7ca736ed66a3.png

I debugged the groupToListOfNames map and saw one of the entries is coming as null and performing trim on null is causing the issue.

Here is the lightning page output, here we can see the first tree value as blank [image: image] <

https://user-images.githubusercontent.com/42802482/236006952-7f90497e-332b-49cc-886a-2aca5c6fb397.png

Let me know if that helps

— Reply to this email directly, view it on GitHub <

https://github.com/trailheadapps/apex-recipes/issues/70#issuecomment-1533495625

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AAYFYWBRXFYGVZ7Q7I5Y7W3XEKN5HANCNFSM4WHXXIZQ

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

Bill C Riemers, PhD, CSM, CSD, A-CSD, SALESFORCE CPD I, SALESFORCE CDL&DA

Senior Principal Software Engineer

Red Hat Canada Ltd https://www.redhat.com/

Enterprise Sales + Services (ESSA) https://red.ht/sig https://patents.justia.com/inventor/bill-c-riemers

— Reply to this email directly, view it on GitHub <

https://github.com/trailheadapps/apex-recipes/issues/70#issuecomment-1533607054

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AKGR2MSC6WV6UPAYSVADAATXEKXO5ANCNFSM4WHXXIZQ

. You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub <

https://github.com/trailheadapps/apex-recipes/issues/70#issuecomment-1534065087

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AAYFYWCLA4COXA6234GZH2TXEMSVVANCNFSM4WHXXIZQ

. You are receiving this because you commented.Message ID: @.***>

--

Bill C Riemers, PhD, CSM, CSD, A-CSD, SALESFORCE CPD I, SALESFORCE CDL&DA

Senior Principal Software Engineer

Red Hat Canada Ltd https://www.redhat.com/

Enterprise Sales + Services (ESSA) https://red.ht/sighttps://patents.justia.com/inventor/bill-c-riemers

— Reply to this email directly, view it on GitHub < https://github.com/trailheadapps/apex-recipes/issues/70#issuecomment-1534847999 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AKGR2MV7CCM2LT7RPGZIEIDXEOZZHANCNFSM4WHXXIZQ

. You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/trailheadapps/apex-recipes/issues/70#issuecomment-1535213785, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYFYWCNDTAW7QNHPCQCFJLXEPXPLANCNFSM4WHXXIZQ . You are receiving this because you commented.Message ID: @.***>

--

Bill C Riemers, PhD, CSM, CSD, A-CSD, SALESFORCE CPD I, SALESFORCE CDL&DA

Senior Principal Software Engineer

Red Hat Canada Ltd https://www.redhat.com/

Enterprise Sales + Services (ESSA) https://red.ht/sighttps://patents.justia.com/inventor/bill-c-riemers