Skip to content

Commit 37fc43f

Browse files
committed
fix: Handle invalid lambda process events
1 parent 37f1b29 commit 37fc43f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

packages/cubejs-serverless-aws/index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@ class AWSHandlers extends Handlers {
2424
}
2525

2626
async process(event) {
27-
await Promise.all(event.Records.map(async record => {
28-
const message = JSON.parse(record.Sns.Message);
29-
await this.processMessage(message);
30-
}));
27+
if (event.Records) {
28+
await Promise.all(event.Records.map(async record => {
29+
const message = JSON.parse(record.Sns.Message);
30+
await this.processMessage(message);
31+
}));
32+
} else {
33+
this.serverCore.logger('Invalid Lambda Process Message', {
34+
warning: `Event doesn't contain Records field. Skipping.`,
35+
lambdaEvent: event
36+
});
37+
}
3138

3239
return {
3340
statusCode: 200

0 commit comments

Comments
 (0)