From e8197449d296786ebc2f8861af385486c395dcbf Mon Sep 17 00:00:00 2001 From: Javier Gutierrez Date: Tue, 26 Jul 2022 10:57:20 +0200 Subject: [PATCH] fix: Preventing that lambda webhook fails when it tries to process a installation_repositories event --- modules/webhook/lambdas/webhook/src/webhook/handler.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/webhook/lambdas/webhook/src/webhook/handler.ts b/modules/webhook/lambdas/webhook/src/webhook/handler.ts index 983a11cf52..58cbf95ddd 100644 --- a/modules/webhook/lambdas/webhook/src/webhook/handler.ts +++ b/modules/webhook/lambdas/webhook/src/webhook/handler.ts @@ -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 { @@ -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;