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.1k stars 1.55k forks source link

During message correlation with `resultEnabled`, wrong entity is populated when "resultType": "Execution" #4310

Closed yanavasileva closed 4 months ago

yanavasileva commented 5 months ago

Environment (Required on creation)

REST API 7.21.0+

Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket)

Perform message correlation with resultEnabled and expected resultType: Execution The resultType isn't considered, always the processInstance entity is returned.

Steps to reproduce (Required on creation)

Get the example from here: https://jira.camunda.com/browse/SUPPORT-21725?focusedCommentId=347192&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-347192

  1. start the application: mvn spring-boot:run
  2. send request for message correlation to start process instance (expected return type: process defintion)
curl --location 'http://localhost:8080/engine-rest/message' \
--header 'Content-Type: application/json' \
--data '{
    "messageName": "startPM",
    "resultEnabled": true
}'
  1. send another request for message correlation
curl --location 'http://localhost:8080/engine-rest/message' \
--header 'Content-Type: application/json' \
--data '{
    "messageName": "startESP",
    "resultEnabled": true
}'

Observed Behavior (Required on creation)

The response contains resultType: Execution and execution: null.

[
    {
        "resultType": "Execution",
        "execution": null,
        "processInstance": {
            "links": [],
            "id": "aa79036a-06d6-11ef-a3f3-00ff18b69f72",
            "definitionId": "81d0b026-06d6-11ef-a3f3-00ff18b69f72",
            "businessKey": null,
            "caseInstanceId": null,
            "ended": false,
            "suspended": false,
            "tenantId": null
        }
    }
]

Expected behavior (Required on creation)

The response contains resultType: Execution and the execution dto is populated.

[
    {
        "resultType": "Execution",
        "execution": {
            "id": "99e27609-06d9-11ef-a41a-00ff18b69f72",
            "processInstanceId": "99e27609-06d9-11ef-a41a-00ff18b69f72",
            "ended": false,
            "tenantId": null
        },
        "processInstance": null
    }
]

(created with 7.20)

Root Cause (Required on prioritization)

Since 7.21.0 the process instance is populated in the result all the time so it can be used in the user operation logs. The REST API, doesn't consider the returnType but checks if the process instance is present: https://github.com/camunda/camunda-bpm-platform/blob/master/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/message/MessageCorrelationResultDto.java#L41-L44 (even thought the execution is also present)

Solution Ideas

Hints

Links

Breakdown

### Pull Requests
- [ ] https://github.com/camunda/camunda-bpm-platform/pull/4321
- [ ] https://github.com/camunda/camunda-bpm-platform-maintenance/pull/1221

Dev2QA handover

yanavasileva commented 4 months ago

Review only of the backport is required. //cc @joaquinfelici