finos / symphony-bdk-java

The Symphony BDK (Bot Developer Kit) for Java helps you to create production-grade Chat Bots and Extension Applications on top of the Symphony REST APIs.
https://symphony-bdk-java.finos.org
Apache License 2.0
23 stars 69 forks source link

FormReplyActivity throws NPE for unchecked checkboxes #427

Closed symphony-enrico closed 3 years ago

symphony-enrico commented 3 years ago

Bug Report

Steps to Reproduce:

  1. Sending an elements form with a checkbox, leaving it unchecked

    <checkbox name="checkbox" value="value">Unchecked</checkbox>
  2. Use FormReplyActivity to getFormValue

    @Override
    public void onActivity(FormReplyContext context) {
      String checkbox = context.getFormValue("checkbox"); // NPE thrown
      this.messageService.send(context.getSourceEvent().getStream(), "hi");
    }

Expected Result:

return null or false instead

Actual Result:

java.lang.NullPointerException: Cannot invoke "com.fasterxml.jackson.databind.JsonNode.asText()" because the return value of "com.fasterxml.jackson.databind.JsonNode.get(String)" is null
    at com.symphony.bdk.core.activity.form.FormReplyContext.getFormValue(FormReplyContext.java:38)
    at com.symphony.GifFormActivity.onActivity(GifFormActivity.java:31)
    at com.symphony.GifFormActivity.onActivity(GifFormActivity.java:12)
    at com.symphony.bdk.core.activity.AbstractActivity.processEvent(AbstractActivity.java:91)
    at com.symphony.bdk.core.service.datafeed.util.RealTimeEventsBinder$2.onSymphonyElementsAction(RealTimeEventsBinder.java:50)
    at com.symphony.bdk.core.service.datafeed.impl.RealTimeEventType.lambda$static$2(RealTimeEventType.java:24)
    at com.symphony.bdk.core.service.datafeed.impl.RealTimeEventType.dispatch(RealTimeEventType.java:73)
    at com.symphony.bdk.core.service.datafeed.impl.AbstractDatafeedLoop.handleV4EventList(AbstractDatafeedLoop.java:85)
    at com.symphony.bdk.core.service.datafeed.impl.DatafeedLoopV1.readAndHandleEvents(DatafeedLoopV1.java:107)
    at com.symphony.bdk.core.retry.RetryWithRecovery.executeOnce(RetryWithRecovery.java:86)
    at io.github.resilience4j.retry.Retry.lambda$decorateCheckedSupplier$3f69f149$1(Retry.java:137)
    at io.github.resilience4j.retry.Retry.executeCheckedSupplier(Retry.java:419)
    at com.symphony.bdk.core.retry.resilience4j.Resilience4jRetryWithRecovery.execute(Resilience4jRetryWithRecovery.java:65)
    at com.symphony.bdk.core.service.datafeed.impl.DatafeedLoopV1.readDatafeed(DatafeedLoopV1.java:119)
    at com.symphony.bdk.core.service.datafeed.impl.DatafeedLoopV1.start(DatafeedLoopV1.java:84)
    at com.symphony.BotApplication.main(BotApplication.java:39)
thibauult commented 3 years ago

Closed by https://github.com/SymphonyPlatformSolutions/symphony-api-client-java/pull/428