Skip to content

fix(langfuse): stop paging when the cursor stops advancing - #5

Merged
hchittanuru3 merged 1 commit into
mainfrom
claude/postflight-issue-review-f1c541
Aug 17, 2026
Merged

fix(langfuse): stop paging when the cursor stops advancing#5
hchittanuru3 merged 1 commit into
mainfrom
claude/postflight-issue-review-f1c541

Conversation

@hchittanuru3

Copy link
Copy Markdown
Contributor

Closes #4.

LangfuseClient.observations() ended its page walk only on a falsy meta.cursor. If the API answers with a cursor echoing the one just sent — a server quirk, a partial-outage response, a proxy replaying a cached page — the loop never terminates. Every page is appended to rows, so this is unbounded rather than merely slow: the same page is re-requested forever, memory grows without limit, and the caller sees no output and no error explaining why.

Change

postflight/adapters/langfuse.py — read the next cursor into nxt and end the walk when it is falsy or equal to the current one.

tests/test_langfuse_adapter.py — a fake client whose two pages return the same cursor, raising IndexError past the last page so an unguarded walk fails loudly instead of hanging the suite. Asserts the request count stops at two, both rows are kept, and the second request actually carried the cursor.

Verification

98 tests pass. The new test fails with IndexError when the one-line fix is reverted.

No behaviour change to any detector.

🤖 Generated with Claude Code

The page walk ended only on a falsy `meta.cursor`. An API that echoes back
the cursor just sent — a server quirk, a partial-outage response, a proxy
replaying a cached page — turned that into an unbounded loop: the same page
re-requested forever, `rows` growing without limit, no output and no error.

End the walk when the cursor repeats. The test drives a fake whose pages
share a cursor and which raises past its last page, so an unguarded walk
fails loudly instead of hanging the suite.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hchittanuru3
hchittanuru3 merged commit 611993c into main Aug 17, 2026
5 checks passed
@hchittanuru3 hchittanuru3 added the bug Something isn't working label Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LangfuseClient.observations() loops forever on a non-advancing cursor

1 participant