From 4989f9c6b39a98170a2ee556c3990005d821cbde Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Wed, 17 Jun 2020 09:44:30 +0200 Subject: [PATCH] fix(hook): check error to avoid panic --- engine/hooks/webhook.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/hooks/webhook.go b/engine/hooks/webhook.go index 2974e4467b..a045c1c7f5 100644 --- a/engine/hooks/webhook.go +++ b/engine/hooks/webhook.go @@ -139,15 +139,15 @@ func executeWebHook(t *sdk.TaskExecution) (*sdk.WorkflowNodeRunHookEvent, error) } //Parse the content type ct, _, _ = mime.ParseMediaType(ct) - switch { - case ct == "application/x-www-form-urlencoded": + switch ct { + case "application/x-www-form-urlencoded": formValues, err := url.ParseQuery(string(t.WebHook.RequestBody)) - if err == nil { + if err != nil { return nil, sdk.WrapError(err, "Unable webhook to parse body %s", t.WebHook.RequestBody) } copyValues(values, formValues) h.Payload["payload"] = string(t.WebHook.RequestBody) - case ct == "application/json": + case "application/json": var bodyJSON interface{} //Try to parse the body as an array