From dd60080b0d19aae6d2cf206809218966c6aca9a5 Mon Sep 17 00:00:00 2001 From: Mojmir Vinkler Date: Tue, 25 Feb 2025 09:24:20 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9D=20Validate=20trailing=20slashes=20?= =?UTF-8?q?of=20envs=20(#3995)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- etl/config.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/etl/config.py b/etl/config.py index 4cd53b2060b..ff33c0213af 100644 --- a/etl/config.py +++ b/etl/config.py @@ -589,3 +589,14 @@ def read_sqls(self, sql: List[str], *args, **kwargs) -> List[pd.DataFrame]: DB_HOST=DB_HOST, ) ) + + +# Validate config +def no_trailing_slash(url: str | None) -> None: + if url is not None and url.endswith("/"): + raise ValueError(f"Env {url} should not have a trailing slash.") + + +env_vars = [ADMIN_HOST, TAILSCALE_ADMIN_HOST, DATA_API_URL, BAKED_VARIABLES_PATH, R2_SNAPSHOTS_PUBLIC_READ] +for env_var in env_vars: + no_trailing_slash(env_var)