Skip to content

Commit

Permalink
Fix 500 error in auth action when url is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
marianobrc committed Dec 27, 2024
1 parent 34004fd commit d3723b9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/actions/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}


Expand Down

0 comments on commit d3723b9

Please sign in to comment.