Skip to content

Commit

Permalink
fix: Preventing that lambda webhook fails when it tries to process an…
Browse files Browse the repository at this point in the history
… installation_repositories event (#2288)
  • Loading branch information
jgutierrezglez authored Aug 3, 2022
1 parent 72f99b7 commit 8656c83
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions modules/webhook/lambdas/webhook/src/webhook/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ export async function handle(headers: IncomingHttpHeaders, body: string): Promis
return response;
}

const payload = JSON.parse(body);
LogFields.fields.event = githubEvent;
LogFields.fields.repository = payload.repository.full_name;
LogFields.fields.action = payload.action;

if (!supportedEvents.includes(githubEvent)) {
logger.warn(`Unsupported event type.`, LogFields.print());
return {
Expand All @@ -42,6 +37,10 @@ export async function handle(headers: IncomingHttpHeaders, body: string): Promis
};
}

const payload = JSON.parse(body);
LogFields.fields.event = githubEvent;
LogFields.fields.repository = payload.repository.full_name;
LogFields.fields.action = payload.action;
LogFields.fields.name = payload[githubEvent].name;
LogFields.fields.status = payload[githubEvent].status;
LogFields.fields.started_at = payload[githubEvent]?.started_at;
Expand Down

0 comments on commit 8656c83

Please sign in to comment.