pull/22766/merge
chenguowei 7 months ago committed by GitHub
commit 2bc49cb3cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -90,10 +90,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:

@ -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"""

@ -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"""

Loading…
Cancel
Save