From b5251c1d63b7801f80428770f468ab5911384c74 Mon Sep 17 00:00:00 2001 From: chenguowei <457219884@qq.com> Date: Tue, 22 Jul 2025 11:52:27 +0800 Subject: [PATCH 1/2] Remove the truncation logic in the validate process --- api/core/ops/utils.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/api/core/ops/utils.py b/api/core/ops/utils.py index 36d060afd2..89755bdbc0 100644 --- a/api/core/ops/utils.py +++ b/api/core/ops/utils.py @@ -88,10 +88,7 @@ def validate_url(url: str, default_url: str, allowed_schemes: tuple = ("https", if parsed.scheme not in allowed_schemes: raise ValueError(f"URL scheme must be one of: {', '.join(allowed_schemes)}") - # Reconstruct URL with only scheme, netloc (removing path, query, fragment) - normalized_url = f"{parsed.scheme}://{parsed.netloc}" - - return normalized_url + return url def validate_url_with_path(url: str, default_url: str, required_suffix: str | None = None) -> str: From 50fb68e2457c1e6343de62945733dff6db18cfbb Mon Sep 17 00:00:00 2001 From: chenguowei <457219884@qq.com> Date: Wed, 23 Jul 2025 14:25:34 +0800 Subject: [PATCH 2/2] fix validate_url test --- api/tests/unit_tests/core/ops/test_config_entity.py | 12 ++++++------ api/tests/unit_tests/core/ops/test_utils.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/tests/unit_tests/core/ops/test_config_entity.py b/api/tests/unit_tests/core/ops/test_config_entity.py index 81cb04548d..df37e918ca 100644 --- a/api/tests/unit_tests/core/ops/test_config_entity.py +++ b/api/tests/unit_tests/core/ops/test_config_entity.py @@ -66,7 +66,7 @@ class TestArizeConfig: def test_endpoint_validation_with_path(self): """Test endpoint validation normalizes URL by removing path""" config = ArizeConfig(endpoint="https://custom.arize.com/api/v1") - assert config.endpoint == "https://custom.arize.com" + assert config.endpoint == "https://custom.arize.com/api/v1" def test_endpoint_validation_invalid_scheme(self): """Test endpoint validation rejects invalid schemes""" @@ -104,7 +104,7 @@ class TestPhoenixConfig: def test_endpoint_validation_with_path(self): """Test endpoint validation normalizes URL by removing path""" config = PhoenixConfig(endpoint="https://custom.phoenix.com/api/v1") - assert config.endpoint == "https://custom.phoenix.com" + assert config.endpoint == "https://custom.phoenix.com/api/v1" class TestLangfuseConfig: @@ -321,7 +321,7 @@ class TestAliyunConfig: config = AliyunConfig( license_key="test_license", endpoint="https://tracing-analysis-dc-hz.aliyuncs.com/api/v1/traces" ) - assert config.endpoint == "https://tracing-analysis-dc-hz.aliyuncs.com" + assert config.endpoint == "https://tracing-analysis-dc-hz.aliyuncs.com/api/v1/traces" def test_endpoint_validation_invalid_scheme(self): """Test endpoint validation rejects invalid schemes""" @@ -366,9 +366,9 @@ class TestConfigIntegration: license_key="test_license", endpoint="https://tracing-analysis-dc-hz.aliyuncs.com/api/v1/traces" ) - assert arize_config.endpoint == "https://arize.com" - assert phoenix_config.endpoint == "https://phoenix.com" - assert aliyun_config.endpoint == "https://tracing-analysis-dc-hz.aliyuncs.com" + assert arize_config.endpoint == "https://arize.com/api/v1/test" + assert phoenix_config.endpoint == "https://phoenix.com/api/v2/" + assert aliyun_config.endpoint == "https://tracing-analysis-dc-hz.aliyuncs.com/api/v1/traces" def test_project_default_values(self): """Test that project default values are set correctly""" diff --git a/api/tests/unit_tests/core/ops/test_utils.py b/api/tests/unit_tests/core/ops/test_utils.py index 7cc2772acf..98c50e34a8 100644 --- a/api/tests/unit_tests/core/ops/test_utils.py +++ b/api/tests/unit_tests/core/ops/test_utils.py @@ -19,17 +19,17 @@ class TestValidateUrl: def test_url_with_path_removed(self): """Test that URL path is removed during normalization""" result = validate_url("https://example.com/api/v1/test", "https://default.com") - assert result == "https://example.com" + assert result == "https://example.com/api/v1/test" def test_url_with_query_removed(self): """Test that URL query parameters are removed""" result = validate_url("https://example.com?param=value", "https://default.com") - assert result == "https://example.com" + assert result == "https://example.com?param=value" def test_url_with_fragment_removed(self): """Test that URL fragments are removed""" result = validate_url("https://example.com#section", "https://default.com") - assert result == "https://example.com" + assert result == "https://example.com#section" def test_empty_url_returns_default(self): """Test empty URL returns default"""