Skip to content

fix(client): don't double the slash after a base_url with a trailing slash - #2136

Open
Sid13SST wants to merge 1 commit into
langfuse:mainfrom
Sid13SST:fix/base-url-trailing-slash
Open

Sid13SST wants to merge 1 commit into
langfuse:mainfrom
Sid13SST:fix/base-url-trailing-slash

Conversation

@Sid13SST

@Sid13SST Sid13SST commented Nov 18, 2026 •

Copy link
Copy Markdown

When base_url ends with a slash (for example http://localhost:3000/), three URLs the SDK builds itself end up with a doubled slash:

  • the OTLP exporter posts spans to //api/public/otel/v1/traces (or //<LANGFUSE_OTEL_TRACES_EXPORT_PATH>)
  • get_trace_url() returns http://localhost:3000//project/...
  • experiment_url in run_experiment has the same //project/... problem

The generated API client already normalizes the base URL, and an existing test asserts _base_url keeps the slash as given, so I left _base_url alone and strip the trailing slash only where these three URLs are built.

Tests: three new unit tests (span exporter path, trace URL, experiment URL). Before the fix they fail ('//api/public/otel/v1/traces' != '/api/public/otel/v1/traces' and http://test.com//project/...); after, they pass. Affected files (test_span_processor.py, test_initialization.py, test_experiment.py): 96 passed. Full tests/unit: 1014 passed, 2 skipped, 26 errors, all in tests/unit/test_prompt.py and identical without this change (missing LANGFUSE_* env vars, #1976); with LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY set: 1040 passed, 2 skipped. ruff check, ruff format --check and mypy langfuse pass. Not run: e2e and live-provider tests (need a Langfuse server and provider keys).

Not covered: a LANGFUSE_OTEL_TRACES_EXPORT_PATH that itself starts with / would still give //.

AI disclosure: Claude (Opus 5.5) found the bug, wrote the fix and tests, and drafted this description. The test runs above were done by the assistant in a cloud sandbox. A person has not yet reviewed the diff line by line beyond confirming scope and authorship; I will respond to review feedback.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

Fixes doubled slashes when a configured base URL ends with /, without changing the stored URL.

  • Span exports use one slash between the base URL and endpoint path.
  • Trace links keep a single slash after the base URL.
  • Experiment links keep a single slash after the base URL.

Sid13SST explicitly left export paths that start with / out of scope; that existing case remains unchanged. No actionable issues found.

Reviews (1) · Last reviewed commit: "fix(client): don't double the slash afte..." · Reviewed by Greptile

…slash

A base_url such as "http://localhost:3000/" was joined with
f"{base_url}/...", so the OTLP exporter posted spans to
"//api/public/otel/v1/traces" and get_trace_url() / experiment_url
returned "http://localhost:3000//project/...". The generated API client
already normalizes this via urljoin; these three URLs bypass it.

Strip the trailing slash where the SDK builds these URLs. _base_url
itself is unchanged.

@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 Nov 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
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.

2 participants