From d3723b9d83a1db2d0d7462c7b01af875f5aa087e Mon Sep 17 00:00:00 2001 From: Mariano Martinez Grasso Date: Fri, 27 Dec 2024 15:58:47 -0300 Subject: [PATCH] Fix 500 error in auth action when url is empty --- app/actions/handlers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/actions/handlers.py b/app/actions/handlers.py index 486c6e9..4e5a20f 100644 --- a/app/actions/handlers.py +++ b/app/actions/handlers.py @@ -25,6 +25,8 @@ async def action_auth(integration: Integration, action_config: AuthenticateConfig): auth_config = action_config url_parse = urlparse(integration.base_url) + if not url_parse.hostname: + return {"valid_credentials": False, "error": f"Site URL is empty or invalid: '{integration.base_url}'"} async with AsyncERClient( service_root=f"{url_parse.scheme}://{url_parse.hostname}/api/v1.0", username=auth_config.username, @@ -46,6 +48,8 @@ async def action_auth(integration: Integration, action_config: AuthenticateConfi except ERClientException as e: # ToDo. Differentiate ER errors from invalid credentials in the ER client return {"valid_credentials": False, "error": str(e)} + except httpx.HTTPError as e: + return {"valid_credentials": False, "error": f"HTTP error: {e}"} return {"valid_credentials": valid_credentials}