Skip to content

Commit

Permalink
fix: Handle invalid lambda process events
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Apr 12, 2020
1 parent 37f1b29 commit 37fc43f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/cubejs-serverless-aws/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ class AWSHandlers extends Handlers {
}

async process(event) {
await Promise.all(event.Records.map(async record => {
const message = JSON.parse(record.Sns.Message);
await this.processMessage(message);
}));
if (event.Records) {
await Promise.all(event.Records.map(async record => {
const message = JSON.parse(record.Sns.Message);
await this.processMessage(message);
}));
} else {
this.serverCore.logger('Invalid Lambda Process Message', {
warning: `Event doesn't contain Records field. Skipping.`,
lambdaEvent: event
});
}

return {
statusCode: 200
Expand Down

0 comments on commit 37fc43f

Please sign in to comment.