fix(trace-item-stats): Resolve issue with pagination#118039
Merged
nsdeschenes merged 1 commit intoJun 19, 2026
Merged
Conversation
The trace item stats endpoint's paginator computes has_more as data[1] >= offset + limit + 1, where data[1] is the second element returned by data_fn. data_fn returned len(request_attrs_list) — the page length after slicing sanitized_keys to [offset : offset + limit] — which is always <= limit. That made has_more always False, so the Link header reported next; results="false" on every page and clients could never paginate past the first page. Return the total number of matching attributes (captured before slicing) as the count so has_more reflects whether more attributes exist beyond the current page. Document the (payload, total_count) contract on the paginator. Rewrite test_pagination_with_limit (which gated its only next-page assertion behind an if that was never true) into test_pagination_traverses_all_pages: it walks both pages and asserts the previous/next results flags and full, non-overlapping attribute coverage. It fails without this fix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
@sentry review |
Contributor
Author
|
@cursor review |
Contributor
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit a06d935. Configure here.
mjq
approved these changes
Jun 19, 2026
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.
Problem
The
/organizations/{org}/trace-items/stats/endpoint never reported a next page, so clients could only ever see the first page of attribute breakdowns.TraceItemStatsPaginatordecides whether there's another page withhas_more = data[1] >= offset + limit + 1, wheredata[1]is the count returned bydata_fn. Butdata_fnreturnedlen(request_attrs_list), the page length after slicingsanitized_keys[offset : offset + limit], which is always ≤limit. That makeshas_morealwaysFalse, so theLinkheader always emittednext; results="false".Fix
total_attributes = len(sanitized_keys)before slicing and return that as the paginator count, sohas_morereflects whether attributes exist beyond the current page.(payload, total_count)contractdata_fnmust satisfy.Closes EXP-1017