Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(api): fix incorrect path handling in Langfuse integration (#22766)

chenguoweifce126b206a7
diff --git a/api/core/ops/entities/config_entity.py b/api/core/ops/entities/config_entity.py
index 89ff0cfded3..626782cee5c 100644
--- a/api/core/ops/entities/config_entity.py
+++ b/api/core/ops/entities/config_entity.py
@@ -102,7 +102,7 @@ class LangfuseConfig(BaseTracingConfig):
@field_validator("host")
@classmethod
def host_validator(cls, v, info: ValidationInfo):
- return cls.validate_endpoint_url(v, "https://api.langfuse.com")
+ return validate_url_with_path(v, "https://api.langfuse.com")
class LangSmithConfig(BaseTracingConfig):
diff --git a/api/core/ops/utils.py b/api/core/ops/utils.py
index 573e8cac883..2c0afb16006 100644
--- a/api/core/ops/utils.py
+++ b/api/core/ops/utils.py
@@ -67,7 +67,13 @@ def generate_dotted_order(
def validate_url(url: str, default_url: str, allowed_schemes: tuple = ("https", "http")) -> str:
"""
- Validate and normalize URL with proper error handling
+ Validate and normalize URL with proper error handling.
+
+ NOTE: This function does not retain the `path` component of the provided URL.
+ In most cases, it is recommended to use `validate_url_with_path` instead.
+
+ This function is deprecated and retained only for compatibility purposes.
+ New implementations should use `validate_url_with_path`.
Args:
url: The URL to validate
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 81cb04548d4..4bcc6cb605e 100644
--- a/api/tests/unit_tests/core/ops/test_config_entity.py
+++ b/api/tests/unit_tests/core/ops/test_config_entity.py
@@ -117,6 +117,13 @@ class TestLangfuseConfig:
assert config.secret_key == "secret_key"
assert config.host == "https://custom.langfuse.com"
+ def test_valid_config_with_path(self):
+ host = host = "https://custom.langfuse.com/api/v1"
+ config = LangfuseConfig(public_key="public_key", secret_key="secret_key", host=host)
+ assert config.public_key == "public_key"
+ assert config.secret_key == "secret_key"
+ assert config.host == host
+
def test_default_values(self):
"""Test default values are set correctly"""
config = LangfuseConfig(public_key="public", secret_key="secret")