Does that happen even if you pass all of the variables setting one of them to null?
If yes. Then try below solution.
As a simple solution (may be not perfect) you can duplicate the task and add an exclusive gateway before them (the 2 tasks).
Task 1 has camunda:assignee="${userAssignment}" Task 2 has camunda:candidateGroups="${groupAssignment}"
The exclusive gateway will direct the execution flow based on the value of userAssignment/groupAssignment
In case userAssignment has a value, execution will go to Task 1
Otherwise (groupAssignment has a value), execution will go to Task 2
I believe Thorben’s solution is the better one.
Use an execution listener on the start event to initialize variables that may be needed later.
I make it a practise to ALWAYS include a script task immediately after the start event to initialize variables the process may need. This is effectively the same as Thorben’s solution so pick your poison.