SMS Notification fallback fails if Engagement report is string instead of map

Description

We're supposed to send the default fall back message if we can't get the study commitment from the Engagement report. However, if the Engagement report is a string instead of a map, we throw an error and fail to send any message at all

2020-04-23 20:17:36,683 ERROR [Thread-8] org.sagebionetworks.bridge.notification.worker.BridgeNotificationWorkerProcessor - Error processing user ID b56ac181-b287-43ce-88b1-6f649b15061a: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 2 path $
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 2 path $
at com.google.gson.Gson.fromJson(Gson.java:899)
at com.google.gson.Gson.fromJson(Gson.java:852)
at com.google.gson.Gson.fromJson(Gson.java:801)
at com.google.gson.Gson.fromJson(Gson.java:773)
at org.sagebionetworks.bridge.rest.RestUtils.toType(RestUtils.java:132)
at org.sagebionetworks.bridge.notification.helper.TemplateVariableHelper.getStudyCommitmentFromReport(TemplateVariableHelper.java:113)
at org.sagebionetworks.bridge.notification.helper.TemplateVariableHelper.getStudyCommitmentUncached(TemplateVariableHelper.java:101)
at org.sagebionetworks.bridge.notification.helper.TemplateVariableHelper.getStudyCommitment_aroundBody0(TemplateVariableHelper.java:84)
at org.sagebionetworks.bridge.notification.helper.TemplateVariableHelper$AjcClosure1.run(TemplateVariableHelper.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.jcabi.aspects.aj.MethodCacher$Tunnel.through(MethodCacher.java:304)
at com.jcabi.aspects.aj.MethodCacher.cache(MethodCacher.java:147)
at org.sagebionetworks.bridge.notification.helper.TemplateVariableHelper.getStudyCommitment(TemplateVariableHelper.java:83)
at org.sagebionetworks.bridge.notification.worker.BridgeNotificationWorkerProcessor.notifyUser(BridgeNotificationWorkerProcessor.java:456)
at org.sagebionetworks.bridge.notification.worker.BridgeNotificationWorkerProcessor.processAccountForDate(BridgeNotificationWorkerProcessor.java:209)
at org.sagebionetworks.bridge.notification.worker.BridgeNotificationWorkerProcessor.accept(BridgeNotificationWorkerProcessor.java:158)
at org.sagebionetworks.bridge.notification.worker.BridgeNotificationWorkerProcessor.accept(BridgeNotificationWorkerProcessor.java:1)
at org.sagebionetworks.bridge.workerPlatform.multiplexer.BridgeWorkerPlatformSqsCallback.callback(BridgeWorkerPlatformSqsCallback.java:51)
at org.sagebionetworks.bridge.sqs.PollSqsWorker.run(PollSqsWorker.java:64)
at java.lang.Thread.run(Thread.java:748)

Environment

None

Assignee

Dwayne Jeng

Reporter

Dwayne Jeng

Labels

None

Validator

Dwayne Jeng

Development Area

None

Release Version History

None

Components

Fix versions

Priority

Major
Configure