-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Tasklist Search query not returning process variables when task is completed or canceled #5502
Description
Environment (Required on creation)
Camunda Self-managed (docker-compose) with version 8.7 - Tasklist (8.7.2)
Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket)
I am trying to call the search tasks API with the option include variables to retrieve the tasks and process variables
It’s working correct when the task state is CREATED but when the task state is converted to CANCELED or COMPLETED the only variables returned are the variables passed in the complete task API only
Steps to reproduce (Required on creation)
Use this test process test.bpmn
I added process variable “requestId” with value “123456”
and in the user task with type Camunda user task I am waiting 2 variable “userId” which I mapped it to the same name and “action” which I mapped it to “employeeAction”.
and these are the requests I sent with the response
first, The search tasks when the task state CREATED
Request:
curl --location 'http://localhost:8082/v1/tasks/search' \ --header 'Content-Type: application/json' \ --data '{ "processInstanceKey": "2251799814193378", "includeVariables": [ { "name": "requestId" }, { "name": "userId" }, { "name": "employeeAction" } ] } '
Response:
[ { "id": "2251799814193384", "name": "User task", "taskDefinitionId": "Activity_0qktzzy", "processName": "Testing process", "creationDate": "2025-10-26T11:19:38.965+0000", "completionDate": null, "assignee": null, "taskState": "CREATED", "sortValues": [ "1761477578965", "2251799814193384" ], "isFirst": true, "formKey": null, "formId": null, "formVersion": null, "isFormEmbedded": null, "processDefinitionKey": "2251799814193186", "processInstanceKey": "2251799814193378", "tenantId": "<default>", "dueDate": null, "followUpDate": null, "candidateGroups": null, "candidateUsers": null, "variables": [ { "id": "2251799814193378-requestId", "name": "requestId", "value": "\"123456\"", "isValueTruncated": false, "previewValue": "\"123456\"" } ], "context": null, "implementation": "ZEEBE_USER_TASK", "priority": 50 } ]
Second, The complete task API
Request:
curl --location 'http://localhost:8088/v2/user-tasks/2251799814193384/completion' \ --header 'Content-Type: application/json' \ --data '{ "variables": { "action": "APPROVE", "userId": "demo" } }'
Response: 204
Third, The serach task API but when the task state is COMPLETED
Request:
curl --location 'http://localhost:8082/v1/tasks/search' \ --header 'Content-Type: application/json' \ --data '{ "processInstanceKey": "2251799814193378", "includeVariables": [ { "name": "requestId" }, { "name": "userId" }, { "name": "employeeAction" }, { "name": "action" } ] } '
Response:
curl --location 'http://localhost:8082/v1/tasks/search' \ --header 'Content-Type: application/json' \ --data '{ "processInstanceKey": "2251799814193378", "includeVariables": [ { "name": "requestId" }, { "name": "userId" }, { "name": "employeeAction" }, { "name": "action" } ] } '
Observed Behavior (Required on creation)
When the task state is CREATED all the variables are returned correct but when the task state is converted into CANCELED or COMPLETED the only variables are returned are the variables that are passed to the complete API and this behaviour happened with the complete API v2 of the Zeebe with tasks of type "Camunda User Task" and not happening with the complete API v1 of the tasklist API with tasks of type "Job Worker".
Expected behavior (Required on creation)
To get the process variables if I added them in the include variables option whatever the task state.
Root Cause (Required on prioritization)
Solution Ideas
Workarounds
Hints
Links
Breakdown
Pull Requests
Dev2QA handover
- Does this ticket need a QA test and the testing goals are not clear from the description? Add a Dev2QA handover comment