JSON payload not passed to service task



I have been working with https://github.com/berndruecker/trip-booking-saga-serverless and trying to get it to work on Camunda Cloud and GCP (using google cloud functions).

I have a cluster running and everything setup correctly.

I have followed every step from your writeup, and everything works as expected EXCEPT the failure conditions, namely, cancelHotel, cancelCar and cancelFlight.

Followed instructions and initiated using:
curl -H "Content-Type: application/json" -X PUT -d @request-zeebe.json https://us-central1-servicemeshes-poc.cloudfunctions.net/bookTrip

I confirmed that the JSON payload is sent over by the initiator function bookTrip:
“bookHotelFailure” : “true”,
“bookCarFailure” : “true”,
“bookFlightFailure”: “false”

I confirmed in the cloud function logs.

This shows up as “variables” at the root level, but amazingly, this payload is NOT sent over to any of the ServiceTasks! And since the bookHotelFailure is undefined in the code:

module.exports.bookCar = (req, res) => {
  const body = req.body;
  let responseBody;
  console.log('carfailure: ' + body.bookCarFailure)
  if (**body.bookCarFailure && body.bookCarFailure==='true'**) {
    console.log('simulated failure to book a car');
    responseBody = JSON.stringify({
      success: false,
      carMessage: 'Car booking went wrong because we wanted it to fail'
  } else {
    console.log('booked a car');    
    responseBody = JSON.stringify({
      success: true,
      carMessage: 'Car booking successful'
  res.status(200).send( responseBody );

I confirmed that the payload received by the Cloud function is undefined. Therefore,
all service tasks simply complete with success = true.

Basically, I am unable to get the payload to pass over from the root scope to any job worker :frowning:

What might be the reason for the payload getting sent to the workflow instance, but not getting propagated over to the Service Task!

Hi @jshah!

I had a quick look at the BPMN workflow. The service tasks uses the HTTP worker to call the functions. The problem here is that the example is a bit outdated.

The behavior of the HTTP worker (and the entire worker itself) has changed in way that the variables are not sent as the body by default anymore (see https://github.com/zeebe-io/zeebe-http-worker/issues/39).

Instead, the body needs to be passed as a variable with name body or as a custom header with name body. For example, by defining an input mapping on the service task:

source: bookHotelFailure
target body.bookHotelFailure

source: bookCarFailure
target body.bookCarFailure

source: bookFlightFailure
target body.bookFlightFailure

Does this help you?

Best regards,


Thanks @philipp.ossler I was able to get the variable passed into the service task but now I got stuck at the Exclusive Gateway.

The service task correctly failed with:
{"success":false,"carMessage":"Car booking went wrong because we wanted it to fail"}

Next, I have setup a default condition, and two separate conditional evaluations:
success == true
success == false

The workflow always picks the default route, and seems to ignore success == false.

I tried changing to “success” == false, but I got an error:

Expected to evaluate condition ‘“success” == false’ successfully, but failed because: Cannot compare values of different types: STRING and BOOLEAN

So how can I code the condition in the SequenceFlow correctly?

Case 1:
Exclusive gateway has a default route and a sequence flow with condition success == false. This completes without taking the failure route (as expected because serviceTask failed previously)!
Case 2:
Exclusive gateway has NO default route and one condition with success == false. This fails with “Expected at least one condition to evaluate to true, or to have a default flow”.

I think I figured it out… added body.success = success as an output parameter to the bookCar service task and this time the Exclusive Gateway was able to route correctly to the cancelCar task!


1 Like

@jshah: Thanks for bringing it up and @philipp.ossler: thanks for the hints!

I updated the example: https://github.com/berndruecker/trip-booking-saga-serverless/commit/6ced85b1deac56107d01fa606c7515229256e5b0

1 Like