From ab3e6da582a922560864eb5e669b3e9d55e54180 Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Mon, 12 May 2025 10:43:53 +0200 Subject: [PATCH] build_dsn: add assertion like the systemcheck from 0c14962d92e4, but dynamically for those environments (non-docker) in which the system-check might be skipped --- compat/dsn.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compat/dsn.py b/compat/dsn.py index 19f2bb2..561ebaa 100644 --- a/compat/dsn.py +++ b/compat/dsn.py @@ -7,6 +7,10 @@ def _colon_port(port): def build_dsn(base_url, project_id, public_key): parts = urllib.parse.urlsplit(base_url) + + assert parts.scheme in ("http", "https"), "The BASE_URL setting must be a valid URL (starting with http or https)." + assert parts.hostname, "The BASE_URL setting must be a valid URL. The hostname must be set." + return (f"{ parts.scheme }://{ public_key }@{ parts.hostname }{ _colon_port(parts.port) }" + f"{ parts.path }/{ project_id }")