From f949747aadca05f746530f261fefabeac3e98230 Mon Sep 17 00:00:00 2001 From: Hassan Abouelela Date: Fri, 4 Jun 2021 06:44:01 +0300 Subject: Handles Null Webhooks The form model specifies webhook as nullable, but the validator code does not properly handle them. This PR adds logic to handle that scenario. Signed-off-by: Hassan Abouelela --- backend/routes/forms/index.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'backend/routes/forms/index.py') diff --git a/backend/routes/forms/index.py b/backend/routes/forms/index.py index 5fd90ab..22171fa 100644 --- a/backend/routes/forms/index.py +++ b/backend/routes/forms/index.py @@ -51,12 +51,14 @@ class FormsList(Route): # Verify Webhook try: # Get url from request - url = form_data[WebHook.__name__.lower()][WebHook.URL.value] + webhook = form_data[WebHook.__name__.lower()] + if webhook is not None: + url = webhook[WebHook.URL.value] - # Validate URL - validation = await validate_hook_url(url) - if validation: - return JSONResponse(validation.errors(), status_code=422) + # Validate URL + validation = await validate_hook_url(url) + if validation: + return JSONResponse(validation.errors(), status_code=422) except KeyError: pass -- cgit v1.2.3