Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: SWITCH task goes through defaultCase if other cases are empty #396

Open
Pabosik opened this issue Feb 14, 2025 · 0 comments
Open

Comments

@Pabosik
Copy link

Pabosik commented Feb 14, 2025

Hello all,

found a bug with task type SWITCH. If the defaultCase contains some task but the other cases do not, the execution will go through the defaultCase even if the SWITCH task correctly evaluated to one of the other branches.

A simple workflow to reproduce:

{
  "createTime": 1739485449420,
  "updateTime": 1739527406013,
  "name": "test_qc_diamond",
  "description": "Edit or extend this sample workflow. Set the workflow name to get started",
  "version": 17,
  "tasks": [
    {
      "name": "qc_action",
      "taskReferenceName": "qc_action",
      "inputParameters": {
        "qc_action_var": "submit"
      },
      "type": "SWITCH",
      "decisionCases": {
        "true": []
      },
      "defaultCase": [
        {
          "name": "terminate_workflow",
          "taskReferenceName": "no_submit_qc_fail",
          "inputParameters": {
            "terminationStatus": "FAILED",
            "terminationReason": "Task QC output was failed.",
            "workflowOutput": "terminated"
          },
          "type": "TERMINATE",
          "decisionCases": {},
          "defaultCase": [],
          "forkTasks": [],
          "startDelay": 0,
          "joinOn": [],
          "optional": false,
          "defaultExclusiveJoinTask": [],
          "asyncComplete": false,
          "loopOver": [],
          "onStateChange": {},
          "permissive": false
        }
      ],
      "forkTasks": [],
      "startDelay": 0,
      "joinOn": [],
      "optional": false,
      "defaultExclusiveJoinTask": [],
      "asyncComplete": false,
      "loopOver": [],
      "evaluatorType": "javascript",
      "expression": "$.qc_action_var == 'submit' ? true : false",
      "onStateChange": {},
      "permissive": false
    }
  ],
  "inputParameters": [],
  "outputParameters": {},
  "schemaVersion": 2,
  "restartable": true,
  "workflowStatusListenerEnabled": false,
  "ownerEmail": "[email protected]",
  "timeoutPolicy": "ALERT_ONLY",
  "timeoutSeconds": 0,
  "variables": {},
  "inputTemplate": {},
  "enforceSchema": true
}

Takes no inputs, just run it from workbench.

This workflow always goes through the defaultCase branch, thus resulting in a workflows status of FAILED, even though it should go through the "true" case and thus skip the termination task and go to the end of workflow having status of COMPLETED.

Please see that even the diagram is wrong:

Image

The evaluation is correctly true, but the termination task is ticked and the arrow is green both on the true branch and going from the termination task towards the end of workflow.

Interestingly, if I place at least one task inside the true branch, the workflow will correctly execute through that branch.

If this is intended behaviour, it is not documented. I consider it a bug.

I have also tried with the value-param evaluator, but the behavior was the same.

Details
Conductor version: 3.21.11 + 69 commits
Persistence implementation: Postgres
Queue implementation: Redis
Lock: Redis

Expected behavior
The workflow should go through the true branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant