Uploaded image for project: 'Kogito'
  1. Kogito
  2. KOGITO-7924

ForEach iterationParam is null when invoking OpenAPI operations

    XMLWordPrintable

Details

    • 2022 Week 35-37 (from Aug 29)

    Description

      See: https://stackoverflow.com/questions/73582629/making-rest-calls-inside-a-serverless-workflows-foreach-state-running-on-kogito/73587509

      In my comment, you can see that for the sysout operation, the parameter item is working fine in the ForEach state.

      But, if the argument is for an openapi function, the iterationParam is null. See the logs:

      2022-09-13 16:48:35,040 DEBUG [org.apa.htt.wire] (executor-thread-0) http-outgoing-0 >> "{"leftElement":null,"rightElement":32.0}"
      

      Using the temperature example:

      {
        "id": "fahrenheit_to_celsius",
        "name": "Fahrenheit to Celsius Conversion Flow",
        "version": "v1.0",
        "start": "SetConstants",
        "functions": [
          {
            "name": "multiplication",
            "operation": "specs/multiplication.yaml#doOperation"
          },
          {
            "name": "subtraction",
            "operation": "specs/subtraction.yaml#doOperation"
          }
        ],
        "states": [
          {
            "name": "SetConstants",
            "type": "inject",
            "data": {
              "subtractValue": 32.0,
              "multiplyValue": 0.5556
            },
            "transition": "Computation"
          },
          {
            "name": "Computation",
            "type": "foreach",
            "inputCollection": ".temperatures",
            "iterationParam": "item",
            "outputCollection": ".products",
            "actions": [
              {
                "name": "subtract",
                "functionRef": {
                  "refName": "subtraction",
                  "arguments": {
                    "leftElement": "${ .item }",
                    "rightElement": "${ .subtractValue }"
                  }
                }
              },
              {
                "name": "multiply",
                "functionRef": {
                  "refName": "multiplication",
                  "arguments": {
                    "leftElement": "${ .difference }",
                    "rightElement": "${ .multiplyValue }"
                  }
                }
              }
            ],
            "end": {
              "terminate": true
            }
          }
        ]
      }
      

      Additionally, there are a few lines indicating an error in the logs, might be related:

      2022-09-13 16:53:31,848 DEBUG [org.jbp.wor.ins.imp.WorkflowProcessInstanceImpl] (executor-thread-0) Signal workItemCompleted received with data WorkItem 5544e75b-0e92-4ae7-82b1-64156321e79a [name=Subtraction_doOperation, state=2, processInstanceId=76c962d0-a5fb-48f5-aa0b-cc324624e276, parameters{leftElement=null, _INPUT_MODEL={"temperatures":[100,200],"subtractValue":32.0,"multiplyValue":0.5556}, rightElement=32.0}] in process instance 76c962d0-a5fb-48f5-aa0b-cc324624e276
      2022-09-13 16:53:31,848 ERROR [org.jbp.wor.ins.imp.NodeInstanceImpl] (executor-thread-0) Could not find variable Computation_6
      2022-09-13 16:53:31,849 ERROR [org.jbp.wor.ins.imp.NodeInstanceImpl] (executor-thread-0) Using process-level scope
      

      Here's the input JSON:

      {"workflowdata" : { "temperatures": [100, 200]  } }
      

      Attachments

        Activity

          People

            ftirados Francisco Javier Tirado Sarti
            rhn-support-zanini Ricardo Zanini Fernandes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: