I'm getting below error when i'm passing some payload to the kafkajs node. I'm using a json node before sending the data to the kafkajs node but still getting the error. Can anyone help here?
{
"level":"ERROR",
"timestamp":"2025-09-23T14:29:37.134Z",
"logger":"kafkajs",
"message":"[Producer] The \"string\" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Array",
"retryCount":0,
"retryTime":314
}
Is that to convert to an object or to convert to a string (i.e. what goes into the JSON node and what comes out of it? - show us before and after payloads)
Function node (forwards array of items) -> split node (separating each payload from the array ) -> json node (to change it from array to json: here the msg.paylaod looks like above) -> kafkajs (here i'm getting the error)
Unfortunately i cannot share the complete msg due to some restriction, should i share any specific part out of it?
You say "Function node (forwards array of items) -> split node (separating each payload from the array ) ->" then you say "json node (to change it from array to json" - so is the original data an array of arrays?
Please verify by way of debug nodes what goes into the kafka node. Screenshot it (you can sanitise/blur out sensitive parts)
A screenshot of your flow (with annotations) would be handy too.
Ok, so you are definitely sending a string payload.
A quick browse of the nodes source code suggests to me if you are using schema validation (useSchemaValidation is true) the string payload WILL get parsed to an object see here - all good!
However, the logic flow suggests that when not using schema validation that the payload should be an object as required by this line of code which is called like so: input msg -> get message values -> getMsgValues -> genRecord (see how it access a sub property from the data as if it were an object?).
I got the solution, actually there was some issue with the split node so instead of using that i wrote a function with same functionality and its working for me.
Just used this function instead of in built split node:
let arr = msg.payload;
let msgs = arr.map(item => {
return {payload: item};
});
return [msgs];