Details
Description
Environment:
Camunda docker image: camunda/camunda-bpm-platform:7.14.0
Description:
The main goal is to retrieve a list of all (unassigned) tasks from the task REST API which does not contain any candidates (CandidateUsers and CandidateGroups).
However the parameter "withoutCandidateGroups": true in combination with "withoutCandidateUsers": true does not work as expected.
Instead the candidate filters are ignored and the result is only filtered by unassigned: true (which is the default case when dealing with candidates).
The current workaround is to make two separate calls to the TASK API, one for withoutCandidateUsers: true, one for withoutCandidateGroups: true and find the intersection of both result sets.
Steps to reproduce:
- Precondition: Multiple tasks with different assignee/candidate combination exist
- Query tasks from the tasks REST API (POSTÂ /task) with the following parameters:
{ "withoutCandidateGroups": true, "withoutCandidateUsers": true }
Observed behavior:
If both parameters are set:
"withoutCandidateGroups": true
"withoutCandidateUsers": true
neither of them are respected.
Expected behavior:
If both parameters withoutCandidateUsers and withoutCandidateGroups are set true, the Task API should
only return unassigned tasks without CandidateUsers and CandidateGroups.
Root Cause:
Current implementation in Task.xml does not respect the case if both parameters are true:
<if test="query.withoutCandidateGroups || query.withoutCandidateUsers"> ${queryType} <trim prefixOverrides="and" prefix="(" suffix=")"> <if test="!query.includeAssignedTasks"> and RES.ASSIGNEE_ is null </if> and NOT EXISTS ( select 1 from ${prefix}ACT_RU_IDENTITYLINK I <where> I.TYPE_ = 'candidate' <if test="query.withoutCandidateGroups"> and I.GROUP_ID_ is not null </if> <if test="query.withoutCandidateUsers"> and I.USER_ID_ is not null </if> AND I.TASK_ID_ = RES.ID_ </where> ) </trim> </if>
The table ACT_RU_IDENTITYLINK only contains entries having either one column CandidateUsers or CandidateGroups set, but never both.
Querying for NOT NULL in both columns will always result in an empty result set here.
Hence, "WHERE NOT EXISTS" always returns all Tasks from ACT_RU_TASK.