akvo / akvo-flow

A data collection and monitoring tool that works anywhere.
http://akvo.org/products/akvoflow/
GNU Affero General Public License v3.0
65 stars 31 forks source link

Failed publishing survey because of group order #3703

Closed muloem closed 2 years ago

muloem commented 3 years ago

Context

Publishing a survey fails with the following exception

 java.lang.NullPointerException
        at com.gallatinsystems.survey.dao.SurveyDAO.loadFullFormIncludingQuestionOptions (SurveyDAO.java:116)
        at com.gallatinsystems.survey.dao.SurveyDAO.loadFullForm (SurveyDAO.java:84)
        at org.waterforpeople.mapping.app.web.SurveyAssemblyServlet.assembleFormWithJackson (SurveyAssemblyServlet.java:170)
        at org.waterforpeople.mapping.app.web.SurveyAssemblyServlet.handleRequest (SurveyAssemblyServlet.java:112)
        at com.gallatinsystems.framework.rest.AbstractRestApiServlet.executeRequest (AbstractRestApiServlet.java:109)
        at com.gallatinsystems.framework.rest.AbstractRestApiServlet.doPost (AbstractRestApiServlet.java:82)
        at com.gallatinsystems.framework.servlet.PersistenceFilter.doFilter (PersistenceFilter.java:71)
        at org.akvo.flow.rest.security.NewUserRegistrationRedirectFilter.doFilter (NewUserRegistrationRedirectFilter.java:66)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter (FilterChainProxy.java:334)
        at org.akvo.flow.rest.security.google.GoogleAuthenticationFilter.doFilter (GoogleAuthenticationFilter.java:90)

Linked to this code: https://github.com/akvo/akvo-flow/blob/19bd5f7dfbc701804b219bea67f7f69a6a0136d4/GAE/src/com/gallatinsystems/survey/dao/SurveyDAO.java#L101-L118

Problem or idea

The qgMap on line 101, is a map of question groups with the question group order as the key. However the exception has been seen in cases where there are two question groups in a single form that have the same order.

Solution or next step

The preventative fix is to make sure all question groups are present when trying to build the map on line 116. However, the real sustainable fix is to make sure the error that creates multiple groups with the same order number is fixed.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.