Adding new Reason gives 500 error with NullPointerException

Description

Description
Adding a new adjustment reason (in Administration > Reasons) gives a 500 error caused by a NullPointerException.

Steps to Reproduce (from test case ):
1. Log in as 'administrator'
2. Navigate to Administration > Reasons
3. Add new reason. Use this name and add two programs in the modal:

name: REASON_1,
category: TRANSFER,
type: Credit,
program: Family Planning, type: Health Center, show: true
program: Essential Meds, type: Health Center, show: false

4. Click Add New Reason to save out of the modal.
5. ERROR: You will get an on-screen error message: "There was an error with this request, please contact the server administrator. No message available". You will also get a green confirmation, and your new reason will appear to be added to the list, but it was actually not configured as a valid reason because of the error. Screenshot attached.

The Scalyr site shows the NullPointerException in /var/log/messages:

java.lang.NullPointerException: null
at org.openlmis.stockmanagement.service.BaseCommunicationService.findOne(BaseCommunicationService.java:88)
at org.openlmis.stockmanagement.service.referencedata.ProgramFacilityTypeExistenceService.checkProgramAndFacilityTypeExist(ProgramFacilityTypeExistenceService.java:46)
at org.openlmis.stockmanagement.web.ValidReasonAssignmentController.checkIsValidRequest(ValidReasonAssignmentController.java:138)
at org.openlmis.stockmanagement.web.ValidReasonAssignmentController.assignReason(ValidReasonAssignmentController.java:133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

This is for this API request in access.log that gives a 500:

12:11:58.442 test.openlmis.org /var/log/nginx/log/access.log 10.0.0.147 - - [23/Mar/2018:19:22:38 +0000] "POST /api/validReasons HTTP/1.1" 500 219

Acceptance Criteria

  • POST /validReasons should work to allow configuring valid reasons.

  • Identify root case of NullPointerException and add automated test so it does not happen again. (This API call definitely works in v3.2.1 so this is a Regression; I confirmed with Postman.) ->

  • Retest from the UI to make sure you can create a new reason and add multiple valid program-facility rows when you Add New Reason (and you do not get any error).

  • Show success notification only when both request pass.

  • UI wasn't updated together with /api/validReasons endpoint. Body send form UI:

    but it should be:

Environment

None

Attachments

1

QAlity Plus - Test Management

Checklists

Activity

Show:

Sam Im 
April 5, 2018 at 10:19 PM

Thanks and good to hear!! Yes you did the right thing, I didn't see it because my filter was checking for the labels of Phase1bug or Phase2bug. So that's my fault. But we need to fix this before we can deploy the release candidate.

Mateusz Kwiatkowski 
April 5, 2018 at 9:51 PM

I was thinking that all bugs found in regression testing should be in roadmap status?
This is actually a quick win, I reported the same bug and proposed a solution, then I've moved it to dead and linked it here. It is

Sam Im 
April 5, 2018 at 9:37 PM

This bug needs to be worked on before the release candidate can be deployed. It was found sitting in Roadmap status.
FYI

Done
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Original estimate

Time tracking

4h logged4h remaining

Components

Sprint

Priority

Time Assistant

Created March 23, 2018 at 7:18 PM
Updated April 6, 2018 at 1:18 PM
Resolved April 6, 2018 at 8:44 AM