4
votes

I have a parallel task in the step function that contains two branches. The input was:

{
  "database": "test",
  "userName": "tester",
  "userID": "test123",
  "adGroup": "testADGroup",
  "dbGroup": "ReadGroup"
}

Each branch return a json result like the following

Branch 1 (I used "OutputPath": "$"):

{
  "requestType": "GrantAccess",
  "DBUser": "exists",
  "ADUser": "exists"
}

Branch 2 (I used "ResultPath": "$.approvalStatus"):

{
      "database": "test",
      "userName": "tester",
      "userID": "test123",
      "adGroup": "testADGroup",
      "dbGroup": "ReadGroup"
      "approvalStatus": "Approved"
}

When both the branches complete, the output of the parallel task return:

[
  {
      "requestType": "GrantAccess",
      "DBUser": "exists",
      "ADUser": "exists"
  },
  {
      "database": "test",
      "userName": "tester",
      "userID": "test123",
      "adGroup": "testADGroup",
      "dbGroup": "ReadGroup"
      "approvalStatus": "Approved"
  }
]

The next task is a choices,

"Choices": [
    {
      "Variable": "$.input[1].approvalStatus",
      "StringEquals": "Approved",
      "Next": "ProcessRequest"
    },
    {
      "Variable": "$.input[1].approvalStatus",
      "StringEquals": "Declined",
      "Next": "SendDeclineNotification"
    }
  ]

and it is keep giving me the following error:

"cause": "An error occurred while executing the state 'CheckApprovalStatus' (entered at the event id #16). Invalid path '$.input[1].approvalStatus': The choice state's condition path references an invalid value."

So here are my questions,

1) How should I reference it in the choice task to get the approvalStatus value?

2) Is there are anyway I can make the parallel task return in json format instead of an array?

Thanks in advance

1
so i think i have solved it by adding "ResultPath":"$.request" in the parallel task, changing branch2 "ResultPath": "$.approvalStatus" to "OutputPath": "$", and change all the reference in the following tasks to "Variable": "$.request[1].approvalStatus" - user3646699
2) I agree. It would be nice if they did it like the node Async module and let you specify parallel states in an object instead of an array and then put the results in an object with the corresponding property names. Relying on array indexes for the parallel results makes the code fragile. - ivo

1 Answers

5
votes

I think you should use something like "$[1].approvalStatus" if you don't want to change the ResultPath.