Repository navigation
Read Langfuse observations with Basic auth and the v2 endpoint - #787
Open
volodymyrshk wants to merge 1 commit into
Open
volodymyrshk wants to merge 1 commit into
volodymyrshk wants to merge 1 commit into
Conversation
`tj backfill langfuse --source-url` sent the key as a Bearer token and read the v1 observations endpoint. - Langfuse gives a Bearer public key a scores-only scope, so reading observations needs Basic auth with the public and secret key. `--api-key` now takes PUBLIC_KEY:SECRET_KEY. A value without a colon is still sent as a Bearer token. - Langfuse Cloud removes the v1 observations endpoint on 16 November 2026 and keeps Observations API v2. The adapter reads v2 with cursor pagination and keeps following the cursor through empty pages, and falls back to v1 on a server that answers 404 for v2. Closes Metabuilder-Labs#785
Contributor
[Medium impact] The PR appears safe to merge; no actionable issues were found.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tj backfill langfuse --source-urlreads observations with a Bearer public key from the old/api/public/observationsendpoint. This PR makes the live mode use the project key pair with Basic auth and the Observations API v2.Two things change:
apiAuth.ts, a Bearer public key getsaccessLevel: "scores", a limited scope. Reading observations needs Basic auth with the public and secret key.--api-keynow takesPUBLIC_KEY:SECRET_KEY. A value without a colon is still sent as a Bearer token, so nothing that worked before stops working./api/public/v2/observations, followsmeta.cursoruntil it is absent (the spec says a page can be empty while a cursor is present, so the old "stop on an empty page" rule would drop data), and falls back to the v1 endpoint with page numbers when the server answers 404 for v2, for example an older self-hosted instance.The field mapping needed no change:
_observation_to_spanalready readsusageDetailsandtotalCost, which are the v2 names.Please read the testing note below. I could not run this against a live Langfuse server.
Related issue
Closes #785
Testing
tests/unit/test_ingest_langfuse.py, usinghttpx.MockTransport(no network): Basic auth for a key pair, Bearer kept for a plain key, v2 with cursors including an empty page that has a cursor, thesincebound, a source URL that already names the old endpoint, the v1 fallback on 404, an auth error is not hidden, and a v2 observation maps to a span. Before the change, four of them fail (it sendsBearer pk:skand calls the v1 path).ruff check tokenjam/andmypy tokenjam/are clean.pytest tests/unit/ tests/synthetic/ tests/agents/ tests/integration/: in a parallel run (-n 4) three tests failed (test_summarize_relocate.py::test_the_cli_says_why_when_nothing_is_offeredand two intest_xdist_isolation.py). The same parallel run on a cleanmainalso fails (five tests, including the same two xdist ones), and all three pass when run serially on this branch.web/public/generated/api/openapi.yml) and the auth behaviour fromapiAuth.ts, not from a run. If you have a Langfuse project key pair you can trytj backfill langfuse --source-url https://cloud.langfuse.com --api-key pk-lf-...:sk-lf-... --since 1donce, that would settle it. I am happy to adjust anything it shows.Checklist
pytest tests/unit/ tests/synthetic/ tests/agents/ tests/integration/), apart from the parallel-run failures described above that also fail onmainruff check tokenjam/)mypy tokenjam/)tests/factories.py(not applicable, the new tests use observation payloads)@anilmurtyas reviewer (@-mentioned here: @anilmurty, this is ready for a look)