From 7cc108226ae5b1d32d9bd55d99a79c38fa6bdf37 Mon Sep 17 00:00:00 2001 From: Roland Takacs Date: Sun, 15 Jun 2025 16:33:48 +0200 Subject: [PATCH 1/2] Fix the parse_cors function to be consistent for both empty string and empty list --- backend/app/core/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/app/core/config.py b/backend/app/core/config.py index d58e03c87d..c808a51a2b 100644 --- a/backend/app/core/config.py +++ b/backend/app/core/config.py @@ -18,6 +18,8 @@ def parse_cors(v: Any) -> list[str] | str: if isinstance(v, str) and not v.startswith("["): + if not v.strip(): + return [] return [i.strip() for i in v.split(",")] elif isinstance(v, list | str): return v From e90d3a24ad9f7960b874d609dbfe67925d1d8b57 Mon Sep 17 00:00:00 2001 From: Roland Takacs Date: Thu, 4 Sep 2025 20:04:27 +0200 Subject: [PATCH 2/2] Update parse_cors function to work for edge case when nothing is provided after or between commas --- backend/app/core/config.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/app/core/config.py b/backend/app/core/config.py index c808a51a2b..40fc1931cb 100644 --- a/backend/app/core/config.py +++ b/backend/app/core/config.py @@ -18,9 +18,7 @@ def parse_cors(v: Any) -> list[str] | str: if isinstance(v, str) and not v.startswith("["): - if not v.strip(): - return [] - return [i.strip() for i in v.split(",")] + return [i.strip() for i in v.split(",") if i.strip()] elif isinstance(v, list | str): return v raise ValueError(v)