Fix pullRelatedField returning empty results on last pagination page#34748
Draft
Fix pullRelatedField returning empty results on last pagination page#34748
Conversation
…ation When offset + limit exceeds the filtered list size, the old code threw IndexOutOfBoundsException which was silently caught, returning an empty list. Replace with Math.min(safeOffset + limit, filteredList.size()) and add a guard for offset > list size. Fixes pullRelatedField failing to return the last page of results. Co-authored-by: fmontes <751424+fmontes@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix pullRelatedField to return last page of results
Fix pullRelatedField returning empty results on last pagination page
Feb 24, 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.
pullRelatedFieldsilently returns 0 results on the last page wheneveroffset + limitexceeds the filtered list size — anIndexOutOfBoundsExceptionis thrown and swallowed, returning an empty list.Root Cause
In
ContentUtils.getPullResults(), thesubListend index was computed asoffset + limitwithout clamping to list bounds. The existing guard (limit >= filteredList.size()) only catches the case where limit alone exceeds the list — not when offset shifts the window past the end.Changes
ContentUtils.getPullResults()— replace rawoffset + limitend index withMath.min(safeOffset + limit, filteredList.size()); guardfromIndexwithMath.min(safeOffset, filteredList.size())to prevent out-of-bounds when offset itself exceeds list size; use immutablesafeOffsetinstead of mutating the parameterContentUtilsTest— addtestPullRelatedField_lastPageReturnsRemainingItems: 4 related items,offset=3 / limit=3→ asserts 1 item returned (the 4th)Checklist
Additional Info
The fix is purely arithmetic — no behavior change for any in-bounds pagination call. The
limit <= 0(fetch-all) path is preserved unchanged.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.