An unclear error is thrown when deploying a workflow

Hello,

I have this error when I deploy a workflow; it appeared recently, and from the stack trace, it’s not my source code, so I’m wondering if someone may have encountered the same issue. By the way, I tried with many BPMN workflows/DMN tables, and I always get the same error:

<rejected> Error: 3 INVALID_ARGUMENT: Property 'variables' is invalid: Expected document to be a root level object, but was 'STRING' : at
 Object.exports.createStatusError (/usr/src/app/node_modules/grpc/src/common.js:91:15) : at Object.onReceiveStatus
 (/usr/src/app/node_modules/grpc/src/client_interceptors.js:1209:28) : at InterceptingListener._callNext
 (/usr/src/app/node_modules/grpc/src/client_interceptors.js:568:42) : at InterceptingListener.onReceiveStatus 
 (/usr/src/app/node_modules/grpc/src/client_interceptors.js:618:8) : at Object.onReceiveStatus 
 (/usr/src/app/node_modules/zeebe-node-affinity/node_modules/zeebe-node/dist/lib/GrpcClient.js:144:36) : at InterceptingListener._callNext 
 (/usr/src/app/node_modules/grpc/src/client_interceptors.js:568:42) : at InterceptingListener.onReceiveStatus
 (/usr/src/app/node_modules/grpc/src/client_interceptors.js:618:8) : at callback (/usr/src/app/node_modules/grpc/src/client_interceptors.js:847:24) { :  code: 3, :  metadata: Metadata { _internal_repr: [Object], flags: 0 }, :  details: "Property 'variables' is invalid: Expected document to be a root level object, but was 'STRING'"     :  } :}

What version is the broker?

The zeebe-node-affinity package hasn’t been updated in a long time, so it may not work with newer brokers - especially it won’t work with 1.0.

It’s difficult to say without seeing the model.

Hello @jwulf

My package.json has

{
    ...
    "zeebe-node": "^0.26.0",
    "zeebe-node-affinity": "^0.19.0"
}

When I start the workflow via Zeebe Modeler, I get the error in my original post. When I look up in Operate, there is no trace of the job.

I have developed a gRPC server that overwrites the Zeebe Gateway methods, so I added some logs in my proxy, and realized this:

async function postCreateWorkflowInstance(config: any) {
  console.log(`[postCreateWorkflowInstance] config ===> ${JSON.stringify(config, null, 2)}`);
  // config.variables is a string!! It should be an object!
  config.variables = JSON.parse(config.variables);
  console.log(
    `[postCreateWorkflowInstance] config after parsing ===> ${JSON.stringify(config, null, 2)}`,
  );
  return await ZB.createWorkflowInstance(config).catch((err) => {
    console.error(`An error occured while creating a workflow instance => ${err}`);
  });
}

async function CreateWorkflowInstance(call: any, callback: any) {
  console.log(`Creating workflow instance...`);
  callback(null, await postCreateWorkflowInstance(call.request));
}

The issue came from the fact that variables should hold an object, not a string!

// this is before parsing
{
  "workflowKey": "0",
  "bpmnProcessId": "email-classifier-test",
  "version": -1,
  "variables": "{}"  // <-- buggy!
}

What I don’t understand is why it has been working two days ago, but since yesterday, this became an issue. This is the part I can’t explain.

Thank you,

1 Like

Yes, the zeebe-node library serialises and deserialises the variables payload, so that in the application domain you are dealing with a JavaScript object.