camunda / camunda-bpm-platform

Flexible framework for workflow and decision automation with BPMN and DMN. Integration with Quarkus, Spring, Spring Boot, CDI.
https://camunda.com/
Apache License 2.0
4.12k stars 1.56k forks source link

Deserialisation fails for objects after saving generic form in Tasklist #2576

Open ThorbenLindhauer opened 3 years ago

ThorbenLindhauer commented 3 years ago

This issue was imported from JIRA:

Field Value
JIRA Link CAM-13463
Reporter @garima-camunda
Has restricted visibility comments true

What are the steps to reproduce your problem?

A sample application is attached for quick reference.

Steps followed



**What is the problem?**  
Deserialization fails for object

**What would be the expected behavior:** 
No error in saving serialized object

**Hints (optional):**

* This always happens when you submit an object variable from the task form (you can also create a new one and look up the variable in the history, it cannot be deserialized as well). 
* The quotation marks used in the serialized String are not handled correctly. This works all fine in the "Add Variable to Process Instance" dialog in Cockpit

**Links:**
* is related to https://jira.camunda.com/browse/SUPPORT-10620
ThorbenLindhauer commented 2 years ago

This comment was imported from JIRA and written by user akPKWEz

What is this name? This pseudonym name was generated based on the user name in JIRA to protect the personal data of our JIRA users. You can use this identifier to search for issues by the same reporter.


This bug makes using the generic task form and using objects in process variables mutually exclusive. Since its mostly about removing one level of escaping, it would be great if this can be fixed soon

nikku commented 1 year ago

I heard rumors that @derari is interested in fixing this issue.

Is there any advice we can give a community contributor on where to dig? I guess it is the core engine, not tasklist failing here?

ThorbenLindhauer commented 1 year ago

Hi Nico,

This needs a fix in tasklist. Tasklist makes the following request:

POST http://localhost:8080/camunda/api/engine/engine/default/task/<task id>/submit-form

{
  "variables": {
    "myPojo": {
      "value": "\"{\\\"prop1\\\":\\\"foo\\\",\\\"prop2\\\":42}\"",
      "type": "Object",
      "valueInfo": {
        "objectTypeName": "org.camunda.bpm.platform.example.servlet.MyPojo",
        "serializationDataFormat": "application/json"
      }
    }
  }
}

whereas the correct request body would be:

{
  "variables": {
    "myPojo": {
      "value": "{\"prop1\":\"foo\",\"prop2\":42}",
      "type": "Object",
      "valueInfo": {
        "objectTypeName": "org.camunda.bpm.platform.example.servlet.MyPojo",
        "serializationDataFormat": "application/json"
      }
    }
  }
}

So a bit too much escaping going on. When fixing this, we should also check if that impacts any of the other variable types and make sure we are not introducing regressions.

Cheers, Thorben

edit: I don't have a pointer to the corresponding code as I'm not that familiar with the frontend code. But happy to let someone else look into this if there is a serious interest in contributing and another hint is needed :)