Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta Para iniciantes
#1,976 3 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@Mathoholic já está trabalhando nisso.

Desde 11/10/2026.

  • #1979 de @Mathoholic — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
80/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
python
Domínio
testing

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

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.

Linguagem predominante
Python
Estrelas
502
Forks
381
Merge médio
1d 1h
PRs com merge (30d)
64

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de langfuse/langfuse-python

Todas as issues de langfuse/langfuse-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.