AshharAhmadKhan opened a new pull request, #6331:
URL: https://github.com/apache/fineract/pull/6331

   https://issues.apache.org/jira/browse/FINERACT-2786
   
   EmailMessageAssembler.assembleFromJson() called EmailMessage.pendingEmail() 
with a hardcoded null emailCampaign. pendingEmail() unconditionally calls 
emailCampaign.getStatus() with no null check, throwing NullPointerException on 
every /v1/email CREATE request regardless of which valid fields are supplied.
   
   The three other callers of pendingEmail() (in 
EmailCampaignWritePlatformCommandHandlerImpl and 
UpdateEmailOutboundWithCampaignMessageTasklet) always pass a real 
EmailCampaign, and email_campaign_id is nullable at the JPA/DB level, 
confirming campaign-less emails were always intended to be valid. EmailMessage 
already has a sibling factory, instance(), which takes an explicit 
EmailMessageStatusType instead of deriving it from emailCampaign.getStatus(), 
so it is null safe by construction and was apparently built for exactly this 
case, just never wired up. Routing the /v1/email assembler to instance() fixes 
the NPE with zero changes to EmailMessage.java itself, so it carries zero risk 
to the three working campaign driven callers of pendingEmail().
   
   Adds a regression test confirming assembleFromJson() no longer throws and 
produces a PENDING EmailMessage when only clientId is supplied.
   
   Related: FINERACT-2785 (validator fix, separate bug, same resource, found 
during the same investigation)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to