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

Kogito Serverless Workflow Grpc Serialization/Deserialization Issues when using enums and inner messages

    XMLWordPrintable

Details

    • False
    • None
    • False
    • Documentation (Ref Guide, User Guide, etc.)
    • Hide

      Create kogito serverless workflow with grpc calls. Send and receive messages with enum and message type fields.

      Show
      Create kogito serverless workflow with grpc calls. Send and receive messages with enum and message type fields.
    • ---
    • ---
    • 2022 Week 26-28 (from Jun 27), 2022 Week 29-31 (from Jul 18)

    Description

      Hi, team!

       

      General brief description.

      I found problems in grpc serelization/deserilisation related behaviour.

      All situations described below was tested on a response messages from the GRPС server to which Kogito Serverless Workflow sends grpc requests.

      All problems is about jackson libraries that Kogito uses for serilisation/deserilisarion to/from grpc <->json.

      I found similar issue for spring boot:

      https://www.javafixing.com/2022/04/fixed-sending-protobuf-as-json-in.html

      Solution described there:

      You might want to use JsonFormat from com.google.protobuf:protobuf-java-util which uses canonical encoding instead of Jackson. 

      Details

      Proto file for reproduce:

      syntax = "proto3";
      option java_multiple_files = true;
      package org.kie.kogito;
      
      service Stock {
        rpc reserve(StockRequest) returns (StockResponse);
      }
      
      message StockRequest {
        string orderId = 1;
      }
      
      message InnerMessage {
        string inStr = 1;
        int64 inLong = 2;
        double inDouble = 3;
      }
      
      message StockResponse {
        enum State {
          UNKNOWN = 0;
          SUCCESS = 1;
          ERROR = 2;
        }
        State state = 1;
        string stateAsString = 2;
        string orderId = 3;
        InnerMessage innerMessage = 4;
      } 

       

      1.Enums:

      1.1. If enum field of response message is set by the value with index 0 - it is not displayed in workflow context/state data like if field is not set or do not exist.

      For our proto file it'll be value UNKNOWN. If we set state and stateAsString fields for response, only stateAsString will be visible in state data json. 

      In serverless workflow nothing unusual:

      "actionDataFilter": {
        "results": ".",
        "toStateData": ".stockResponse"
      } 

      Current behavior: Under stockResponse will be no state field, will be only stateAsString field.

      Expected behavior: ** Fields with the type of enum deserilize and displays in the state data the same as the grpc server were sent.

      1.2. If enum field of response message is set by the value with index more than 0.

      Current behavior:  It leads to stackoverflow. Stack: Enum field with value for index 1 stackoverflow.rtf

      Expected behavior: ** No exceptions. ** Fields with the type of enum deserilize and displays in the state data the same as the grpc server were sent.

       

      2. Nested messages.

      Current behavior:  If we'll set the field innerMessage field from proto example below It will lead to exception on kogito side. Stack: Nested message jackson deserialize ex.rtf

      Expected behavior: ** No exceptions. ** Fields with the type message deserilize and displays in the state data the same as the grpc server were sent.

      Attachments

        Issue Links

          Activity

            People

              ftirados Francisco Javier Tirado Sarti
              ilfirinoro5@gmail.com Andrey Kazantsev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: