Skip to content

test(pagination): preserve item limits when consumers clear pages - #2129

Open
Sampsonyu wants to merge 1 commit into
langfuse:mainfrom
Sampsonyu:test/pagination-max-items-consumed-pages
Open

Sampsonyu wants to merge 1 commit into
langfuse:mainfrom
Sampsonyu:test/pagination-max-items-consumed-pages

Conversation

@Sampsonyu

@Sampsonyu Sampsonyu commented Nov 13, 2026 •

Copy link
Copy Markdown

What does this PR do?

Add regression coverage for the row-counting fix in #2101. A caller may clear a page's data after processing it to release memory. The iterator must still count those rows toward max_items.

Exercise both Langfuse.iter_observation_pages and Langfuse.aiter_observation_pages with a three-item cap. The tests consume and clear each page, then verify that only three observation IDs are delivered and that the final request is limited to one remaining item. A further scripted page is available to expose an extra fetch.

This is a test-only contribution. The current implementation already counts rows before yielding; runtime code is unchanged.

Type of change

  • Other: regression test coverage

Verification

uv sync --locked
uv run --frozen pytest tests/unit/test_pagination.py -q
uv run --frozen ruff check tests/unit/test_pagination.py
uv run --frozen ruff format --check tests/unit/test_pagination.py
git diff --check

The original pagination suite passes 10 cases; the expanded suite passes 12, including both new sync/async cases. Tests use the existing scripted API fixture and require no Langfuse server or model calls. The repository-wide suite, e2e tests and live-provider tests were not run for this single test-file change.

Checklist

  • The diff was reviewed using code_review.md.
  • Regression coverage was added and passes.
  • Documentation changes are unnecessary for this test-only addition.
  • No generated files or credentials are changed.

RetriggerView in GreptileConfidence Score: 5/5

This test-only PR appears safe to merge.

Summary

Adds sync and async regression tests for callers that clear page.data after reading it.

  • Pagination tests cover callers clearing yielded pages.

Reviews (1) · Last reviewed commit: "test(pagination): preserve item limits w..." · Reviewed by Greptile

@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 13, 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