tests/unit/test_prompt.py fails on a fresh clone without LANGFUSE_* env vars
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 80/100
Direção de pesquisa
A configuração que falha é o fixture langfuse em tests/unit/test_prompt.py:132, que chama Langfuse() sem argumentos. Reproduza removendo as variáveis LANGFUSE_* e executando uv run --frozen pytest tests/unit/test_prompt.py -q, depois compare com o env no nível do job em .github/workflows/ci.yml:65-67. Está concluído quando os 18 erros desaparecem sem variáveis de ambiente, ou quando o CONTRIBUTING.md documenta os exports necessários. Confirme com um mantenedor qual das duas correções propostas ele prefere antes de editar.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 502
- Forks
- 381
- Merge médio
- 1d 1h
- PRs com merge (30d)
- 64
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de langfuse/langfuse-python
-
bug(scores): create_score sends numpy.bool_ as JSON `true` and Decimal as "<Decimal>" since v5.0.2Talvez já em andamento @lalith0407 assumiu há 2 dias. Abertabug feat-scores sdk-python
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
langfuse/langfuse-python#2057 ·
Mantenedores costumam responder em até 1 dia
-
bug(openai): a stream that fails mid-iteration ends the generation without level ERRORTalvez já em andamento @hassiebp assumiu há 5 dias. Abertabug integration-openai sdk-python
langfuse/langfuse-python#2039 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
fix(serializer): handle single-string __slots__ and detect cycles in slotted objectsTalvez já em andamento @hassiebp assumiu há 11 dias. Abertabug sdk-python
langfuse/langfuse-python#2014 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
bug: ChatPromptClient.compile appends str(whole list) once per non-dict placeholder itemTalvez já em andamento @nimarb assumiu há 6 dias. Abertabug feat-prompt-management sdk-python
langfuse/langfuse-python#1971 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
bug: GCS upload detection in MediaManager uses substring match on the full URLTalvez já em andamento @hassiebp assumiu há 27 dias. Abertabug feat-multimodal-media sdk-python
langfuse/langfuse-python#1913 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de langfuse/langfuse-python
Issues semelhantes
-
bug P1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Toloka/tolokaforge#1947 ·
Mantenedores costumam responder em até 1 dia
-
SageMaker provider: streaming fails with NoStreamDataError on DJL Serving (LMI) endpointsTalvez já em andamento @balajiaru assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
UKGovernmentBEIS/inspect_ai#6127 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
pydot/pydot#601 · 4 comentários ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
letsencrypt/cp-cps#361 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100