Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

tests/unit/test_prompt.py fails on a fresh clone without LANGFUSE_* env vars

未关闭 适合新手
#1,976 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@Mathoholic 已经在做这个了。

开始于 2026年10月11日。

  • #1979 来自 @Mathoholic —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
80/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
testing

调研方向

失败的设置是 tests/unit/test_prompt.py:132 处的 langfuse fixture,它不带参数调用 Langfuse()。取消设置 LANGFUSE_* 变量并运行 uv run --frozen pytest tests/unit/test_prompt.py -q 进行复现,然后与 .github/workflows/ci.yml:65-67 中的作业级环境变量进行比较。完成标准是:在没有环境变量的情况下 18 个错误消失,或者 CONTRIBUTING.md 记录了所需的导出变量。在编辑之前,请与维护者确认他们更倾向于两个建议修复方案中的哪一个。

由索引模型根据 Issue 内容生成。

描述

bug feat-prompt-management sdk-python

CONTRIBUTING.md says unit tests don't require a running Langfuse server, but on a fresh clone with no LANGFUSE_* env vars set, 18 tests in tests/unit/test_prompt.py error during fixture setup:

AttributeError: Langfuse client is not initialized
langfuse/_client/client.py:497

The langfuse fixture (tests/unit/test_prompt.py:132) calls Langfuse() with no arguments. Without LANGFUSE_PUBLIC_KEY, the client initializes as disabled (_resources is None), so the api setter raises when the fixture assigns Mock().

Repro (latest main):

uv sync --locked
env -u LANGFUSE_PUBLIC_KEY -u LANGFUSE_SECRET_KEY -u LANGFUSE_BASE_URL \
  uv run --frozen pytest tests/unit/test_prompt.py -q
# 8 passed, 18 errors

With dummy keys exported, all 26 pass (full tests/unit: 885 passed).

This passes in CI because the unit-test job sets LANGFUSE_PUBLIC_KEY=pk-lf-test, LANGFUSE_SECRET_KEY=sk-lf-test and LANGFUSE_BASE_URL=http://localhost:3000 at the job level (.github/workflows/ci.yml:65-67), so the gap only shows up locally.

Proposed fix (either works, happy to go with whichever you prefer):

  1. Pass the same dummy credentials CI uses explicitly in the fixture, e.g. Langfuse(public_key="pk-lf-test", secret_key="sk-lf-test", base_url="http://localhost:3000"), so tests/unit is self-contained as CONTRIBUTING.md describes.
  2. Or, if relying on env vars is intentional, add a note to CONTRIBUTING.md telling contributors to export these values before running unit tests.

Happy to open a PR if this is welcome.

主要语言
Python
星标
498
派生
361
平均合并
16 小时 40 分钟
30 天内合并 PR
38

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

langfuse/langfuse-python 的其他 Issue

查看 langfuse/langfuse-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。