
TypeError: OfflineSectionEvaluator._get_dataset_items.
快速结论:当 Langfuse Python SDK 尝试获取名称包含斜杠(如 “root/children”)的 dataset 时,会因 SDK 对名称进行双重 URL 编码而返回 404。优先排查 dataset 名称中是否包含 “/” 字符,并尝试绕过编码。
问题场景
用户在 Langfuse Cloud(Python SDK)中创建了一个文件夹格式的 dataset(名称格式如 “root/children”),随后使用 self.langfuse.get_dataset(self.dataset_name) 获取该 dataset,结果返回 HTTP 404 错误。
报错原文
# 调用 get_dataset("root/children") 时返回 404
# SDK 内部错误日志可能包含:
# HTTP 404 - Not Found
# 或类似: langfuse.client - dataset not found for name "root%2Fchildren"
原因分析
这是一个已知 bug:Langfuse Python SDK 的 _url_encode 方法会对 dataset 名称中的斜杠 “/” 进行 URL 编码(变为 “%2F”),然后发送给后端 API。但后端 API 期望接收原始的、未编码的名称(包括斜杠)进行精确匹配。因为双重编码导致后端找不到对应的 dataset,从而返回 404。
环境排查
- 确认使用的是 Langfuse Python SDK(版本不限,任何包含
_url_encode方法的版本均受影响) - 确认 dataset 名称中是否包含斜杠 “/”(如 “root/children”、”parent/child” 等文件夹格式)
- 确认是否在 Langfuse Cloud 环境下运行(self-hosted 用户同样受影响)
解决步骤
-
绕过 SDK 编码(推荐):在获取 dataset 之前,暂时覆盖 SDK 的
_url_encode方法,使其直接返回原始名称,避免双重编码。from langfuse import Langfuse lf_client = Langfuse() # 关键修复:绕过 SDK 的 URL 编码 lf_client._url_encode = lambda x: x # 现在可以正常获取带有斜杠的 dataset dataset = lf_client.get_dataset("root/children") -
方案二(临时补丁):直接修改 SDK 源代码。编辑
langfuse/_client/client.py文件,将dataset_name=self._url_encode(name)改为dataset_name=name。如果使用虚拟环境或容器,需要注意补丁会在更新 SDK 后被覆盖。 -
规避方法:避免在 dataset 名称中使用斜杠 “/”,或改用其他分隔符(如下划线 “_”)来构建文件夹层级,直到官方修复此 bug。
验证方法
在应用上述修复后,再次运行 lf_client.get_dataset("root/children") 应成功返回对应的 dataset 对象,而不是抛出 404 异常。可以通过检查返回对象的 name 属性确认是正确名称。

![[BUG]: Error: SQLite database error](https://www.chat-gpts.plus/wp-content/uploads/2026/07/2564-70af5d26-768x403.jpg)

