Skip to content

Commit

Permalink
add descriptive error message for unparseable endpoint value
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdunnjpl committed Sep 12, 2023
1 parent aa747c6 commit 9a863f0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pds/registrysweepers/utils/db/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ def get_opensearch_client_from_environment(verify_certs: bool = True) -> OpenSea


def get_opensearch_client(endpoint_url: str, username: str, password: str, verify_certs: bool = True) -> OpenSearch:
scheme, host, port = endpoint_url.replace("://", ":", 1).split(":")
try:
scheme, host, port_str = endpoint_url.replace("://", ":", 1).split(":")
port = int(port_str)
except ValueError:
raise ValueError(
f'Failed to parse (scheme, host, port) from endpoint value - expected value of form <scheme>://<host>:<port> (got "{endpoint_url}")'
)

use_ssl = scheme.lower() == "https"
auth = (username, password)

Expand Down

0 comments on commit 9a863f0

Please sign in to comment.