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
- 星號
- 504
- 分支
- 391
- 平均合併
- 1 天 3 小時
- 30 天內合併 PR
- 74
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
langfuse/langfuse-python 的其他 Issue
-
bug(scores): create_score sends numpy.bool_ as JSON `true` and Decimal as "<Decimal>" since v5.0.2可能已有人在做 @lalith0407 於 9 天前認領。 未關閉bug feat-scores sdk-python
難度 2/5 1-3 小時 新手友好度 74/100
langfuse/langfuse-python#2057 ·
維護者通常 1 天內回覆
-
bug(openai): a stream that fails mid-iteration ends the generation without level ERROR可能已有人在做 @hassiebp 於 12 天前認領。 未關閉bug integration-openai sdk-python
langfuse/langfuse-python#2039 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
fix(serializer): handle single-string __slots__ and detect cycles in slotted objects可能已有人在做 @hassiebp 於 18 天前認領。 未關閉bug sdk-python
langfuse/langfuse-python#2014 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
bug: ChatPromptClient.compile appends str(whole list) once per non-dict placeholder item可能已有人在做 @nimarb 於 12 天前認領。 未關閉bug feat-prompt-management sdk-python
langfuse/langfuse-python#1971 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
bug: GCS upload detection in MediaManager uses substring match on the full URL可能已有人在做 @hassiebp 於 33 天前認領。 未關閉bug feat-multimodal-media sdk-python
langfuse/langfuse-python#1913 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
查看 langfuse/langfuse-python 的全部 Issue
相似的 Issue
-
Import errors are swallowed: PerthImplicitWatermarker silently becomes None可能已有人在做 @JonRC 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
resemble-ai/Perth#23 ·
-
correction metadata
難度 2/5 1 小時以內 新手友好度 65/100
acl-org/acl-anthology#10753 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
earthtojake/text-to-cad#758 ·
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 70/100
DataTalksClub/faq#545 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆