Skip to main content
Question

Not able to determine the behaviour of a task onFailure

  • 21 March 2024
  • 4 replies
  • 32 views

Hello team, 

I was trying to trigger a workflow by passing the workflow input tasks and setting the onFailure to skipTask, as I did not want my workflow to be aborted if some task fails.

Despite of triggering the workflow by sdk and passing the workflow input.,

I can see that the workflow has been trigerred but with onFailure to be abortWorkflow

Could you please help me with solving this.

 

code for triggering workflow:

workflow_input = {

    "tasks": t

  {

    "externalId": "gb-test-func-1",

    "type": "function",

    "name": "1710479974441",

    "parameters": {

      "function": {

        "externalId": "gb-test-func-1",

        "data": {}

      }

    },

    "onFailure": "skipTask",

    "dependsOn": "]

  },

  {

    "externalId": "gb-test-func-2",

    "type": "function",

    "name": "1710482066717",

    "parameters": {

      "function": {

        "externalId": "gb-test-func-2",

        "data": {}

      }

    },

    "onFailure": "skipTask",

    "dependsOn":  

      {

        "externalId": "gb-multiplication-by-2"

      }

    ]

  },

  {

    "externalId": "gb-multiplication-by-2",

    "type": "function",

    "name": "1710927303699",

    "parameters": {

      "function": {

        "externalId": "gb-multiplication-by-2",

        "data": {}

      }

    },

    "onFailure": "skipTask",

    "dependsOn":

      {

        "externalId": "gb-test-func-1"

      }

    ]

  }

]

}

client.workflows.executions.trigger(

    workflow_external_id='gargi-test-workflow', version=2, input=workflow_input

)

4 replies

Userlevel 4

Hi @Gargi Bhosale! Are you able to share your workflow definition? 

Userlevel 1
Badge

sure,

[ { "externalId": "gb-test-func-1", "type": "function", "name": "1710479974441", "parameters": { "function": { "externalId": "gb-test-func-1", "data": {} } }, "onFailure": "abortWorkflow", "dependsOn": [] }, { "externalId": "gb-test-func-2", "type": "function", "name": "1710482066717", "parameters": { "function": { "externalId": "gb-test-func-2", "data": {} } }, "onFailure": "abortWorkflow", "dependsOn": [ { "externalId": "gb-multiplication-by-2" } ] }, { "externalId": "gb-multiplication-by-2", "type": "function", "name": "1710927303699", "parameters": { "function": { "externalId": "gb-multiplication-by-2", "data": {} } }, "onFailure": "abortWorkflow", "dependsOn": [ { "externalId": "gb-test-func-1" } ] } ]

Userlevel 4

The workflow definition determines the tasks (steps) of the workflow, their individual configurations, and their dependencies. 

In your case, the workflow will execute gb-test-func-1 → gb-multiplication-by-2 → gb-test-func-2. All tasks are configured to have "onFailure": "abortWorkflow" , meaning the workflow will be marked as failed if any of the tasks fail. 

In the workflow input, you can pass data that will be accessible to the tasks inside the workflow during execution. The tasks in the workflow definition would need to reference the input, see this section of the documentation for more details.

Your workflow definition does not reference the workflow input anywhere, so it will not be taken into account. What you need to do is update the workflow definition itself, replacing the current one (last post) with what you would like it to be (first post). If you want to determine the tasks to be executed in the workflow through the workflow input, you can have a look at the Dynamic Task.

Let me know if you have further questions!

Userlevel 4
Badge +2

Hi @Gargi Bhosale,

We are following up to see whether you're satisfied with the responses you've received? 

Reply