tests/unit/test_prompt.py fails on a fresh clone without LANGFUSE_* env vars
维护者通常 1 天内回复
评估
调研方向
失败的设置是 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 内容生成。
描述
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):
- 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"), sotests/unitis self-contained as CONTRIBUTING.md describes. - 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
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
langfuse/langfuse-python 的其他 Issue
-
bug(langchain): failed streaming LLM runs retain IDs in callback memo可能已有人在做 @hassiebp 于 1 天前认领。 未关闭bug integration-langchain sdk-python
langfuse/langfuse-python#1977 · 已指派 1 人 ·
维护者通常 1 天内回复
-
bug: ChatPromptClient.compile appends str(whole list) once per non-dict placeholder item可能已有人在做 @hassiebp 于 3 天前认领。 未关闭bug feat-prompt-management sdk-python
langfuse/langfuse-python#1971 · 已指派 1 人 ·
维护者通常 1 天内回复
-
bug: LANGFUSE_MAX_EVENT_SIZE_BYTES is parsed but never enforced for score events可能已有人在做 @hassiebp 于 3 天前认领。 未关闭bug feat-scores sdk-python
langfuse/langfuse-python#1966 · 已指派 1 人 ·
维护者通常 1 天内回复
-
bug: non-numeric status in a 207 error entry raises inside handle_exception, kills the score consumer thread, flush()/shutdown() then hang可能已有人在做 @hassiebp 于 3 天前认领。 未关闭[Integrations] Language Clients bug feat-scores sdk-python
langfuse/langfuse-python#1967 · 已指派 1 人 ·
维护者通常 1 天内回复
-
bug: Partial-failure (207) ingestion response retries the whole batch up to 3x; per-item error details only logged at DEBUG可能已有人在做 @hassiebp 于 3 天前认领。 未关闭bug feat-ingestion
langfuse/langfuse-python#1965 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 langfuse/langfuse-python 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 75/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
Status: Triage Type: Bug
难度 2/5 1-3 小时 新手友好度 86/100
-
Objects.List treats versions=false (and similar flags) as true可能已有人在做 @andaaron 今天认领。 未关闭priority: p2 type: bug
难度 2/5 1-3 小时 新手友好度 78/100
googleapis/storage-testbench#829 ·
维护者通常 2 天内回复
-
[Bug]: memory provider treats 1:1 DMs as shared surfaces, so DM turns never receive reviewed records未关闭
难度 2/5 1-3 小时 新手友好度 79/100
rlaope/oh-my-hermes#2088 ·
维护者通常 1 天内回复