Skip to content

fix: update env template to use LANGFUSE_BASE_URL#1701

Merged
hassiebp merged 2 commits into
langfuse:mainfrom
milanagm:milanagm/lfe-10249-env-template-base-url
Jun 11, 2026
Merged

fix: update env template to use LANGFUSE_BASE_URL#1701
hassiebp merged 2 commits into
langfuse:mainfrom
milanagm:milanagm/lfe-10249-env-template-base-url

Conversation

@milanagm

@milanagm milanagm commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Closes LFE-10249

What does this PR do?

A contributor who follows CONTRIBUTING.md set up langfuse-python and to run the E2E test suite hits a KeyError before any test runs, because .env.template does not include LANGFUSE_BASE_URL, which the test infrastructure hard-requires.

Root cause

LANGFUSE_BASE_URL is the canonical env var in v4; LANGFUSE_HOST is deprecated (AGENTS.md:131, code_review.md:14).

The SDK client itself works with either — reads LANGFUSE_BASE_URL first, falls back to LANGFUSE_HOST (langfuse/_client/client.py:258-263).

But the test infra has no fallback: tests/support/api_wrapper.py:19 uses os.environ["LANGFUSE_BASE_URL"] (subscript → KeyError if unset). tests/support/utils.py:72 passes os.environ.get("LANGFUSE_BASE_URL") (→ None), which then hits that subscript.

.env.template ships only LANGFUSE_HOST, never LANGFUSE_BASE_URL.

CONTRIBUTING.md:39 tells contributors to set up E2E env vars "based on .env.template".

5 of 8 files in tests/e2e/ call get_api() / LangfuseAPI, so all of them fail without the var.

Steps to reproduce

cp .env.template .env and fill in keys (per CONTRIBUTING).

Start a local Langfuse server.

Run uv run --frozen pytest -n 4 --dist worksteal tests/e2e -m "not serial_e2e".

Result: errors/failures originating from KeyError('LANGFUSE_BASE_URL').

Minimal repro (no server needed):

$ env -i LANGFUSE_HOST=http://localhost:3000/ \

LANGFUSE_PUBLIC_KEY=pk-lf-... LANGFUSE_SECRET_KEY=sk-lf-... \
python -c "from tests.support.api_wrapper import LangfuseAPI; LangfuseAPI(base_url=None)"

KeyError: 'LANGFUSE_BASE_URL'

Greptile Summary

This PR fixes a contributor-facing DX issue: .env.template was missing LANGFUSE_BASE_URL (the canonical v4 env var), causing a KeyError before any E2E test ran when following the CONTRIBUTING.md setup steps. The fix adds LANGFUSE_BASE_URL as the primary entry and retains LANGFUSE_HOST with a deprecation comment.

  • Adds LANGFUSE_BASE_URL=http://localhost:3000 to .env.template, matching what tests/support/api_wrapper.py:19 requires via os.environ["LANGFUSE_BASE_URL"].
  • Keeps LANGFUSE_HOST in the template with an inline comment marking it deprecated, which preserves backward-compat awareness but introduces a minor risk (see comment).

Confidence Score: 5/5

Safe to merge — a one-line template addition that unblocks E2E tests for new contributors without touching any runtime code.

The change is confined to .env.template, adds exactly the missing variable that tests/support/api_wrapper.py hard-requires, and introduces no logic changes. The only minor concern is the inline comment on the deprecated LANGFUSE_HOST line, which could confuse non-python-dotenv tooling.

No files require special attention; .env.template is the only changed file and the fix is straightforward.

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
.env.template:3
Inline comments in `.env` files are handled inconsistently across tooling. `python-dotenv` strips them correctly, but `source .env` in bash or `export $(cat .env | xargs)` would set `LANGFUSE_HOST` to the literal string `http://localhost:3000  # deprecated alias for LANGFUSE_BASE_URL`, breaking any fallback path that reads `LANGFUSE_HOST`. Since `LANGFUSE_BASE_URL` is now in the template and is the canonical var, moving the deprecation note to its own comment line avoids this entirely.

```suggestion
# LANGFUSE_HOST is a deprecated alias for LANGFUSE_BASE_URL
LANGFUSE_HOST=http://localhost:3000
```

Reviews (1): Last reviewed commit: "add LANGFUSE_BASE_URL to .env.template s..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@CLAassistant

CLAassistant commented Jun 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread .env.template Outdated

@hassiebp hassiebp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Milana! Could you please update the PR title to follow semantic commit convention? See also for other commits in this repo

Comment thread .env.template Outdated
@milanagm milanagm changed the title langfuse-python: .env.template missing LANGFUSE_BASE_URL leading to E2E tests failing out-of-the-box fix: update env template to use LANGFUSE_BASE_URL Jun 11, 2026
@milanagm milanagm force-pushed the milanagm/lfe-10249-env-template-base-url branch from 09ff509 to 697ec55 Compare June 11, 2026 09:11
@hassiebp hassiebp self-requested a review June 11, 2026 11:01
@hassiebp

Copy link
Copy Markdown
Collaborator

Thanks for your contribution, @milanagm 🥳

@hassiebp hassiebp merged commit 9cfee9f into langfuse:main Jun 11, 2026
1 check passed
@milanagm milanagm deleted the milanagm/lfe-10249-env-template-base-url branch June 12, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants