Skip to content

Commit

Permalink
fix: check for erroneous events
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwal-ab committed Oct 5, 2023
1 parent a838984 commit 556641f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/v0/destinations/kafka/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
getHashFromArray,
removeUndefinedAndNullValues,
getSuccessRespEvents,
getErrorRespEvents,
} = require('../../util');
// const { InstrumentationError } = require("../../util/errorTypes");

Expand Down Expand Up @@ -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];

Check warning on line 44 in src/v0/destinations/kafka/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/kafka/transform.js#L43-L44

Added lines #L43 - L44 were not covered by tests
}

// Grouping the events by topic
const groupedEvents = groupBy(destEvents, (event) => event.message.topic);
Expand Down

0 comments on commit 556641f

Please sign in to comment.