diff --git a/src/v0/destinations/kafka/transform.js b/src/v0/destinations/kafka/transform.js index d254ba882a..39334b5f52 100644 --- a/src/v0/destinations/kafka/transform.js +++ b/src/v0/destinations/kafka/transform.js @@ -6,6 +6,7 @@ const { getHashFromArray, removeUndefinedAndNullValues, getSuccessRespEvents, + getErrorRespEvents, } = require('../../util'); // const { InstrumentationError } = require("../../util/errorTypes"); @@ -38,6 +39,10 @@ const filterConfigTopics = (message, destination) => { const batch = (destEvents) => { const respList = []; + if (!Array.isArray(destEvents) || destEvents.length <= 0) { + const respEvents = getErrorRespEvents(null, 400, 'Invalid event array'); + return [respEvents]; + } // Grouping the events by topic const groupedEvents = groupBy(destEvents, (event) => event.message.topic);