Skip to content

Commit

Permalink
fix: Preventing that lambda webhook fails when it tries to process a …
Browse files Browse the repository at this point in the history
…installation_repositories event
  • Loading branch information
jgutierrezglez committed Jul 26, 2022
1 parent d5fbab1 commit e819744
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 e819744

Please sign in to comment.