Skip to content

fix: Avoid division by zero in UAA pagination (5.x.x) - #1473

Open
ZPascal wants to merge 2 commits into
cloudfoundry:5.x.xfrom
ZPascal:fix-uaa-pagination-div-zero-5.x.x
Open

ZPascal wants to merge 2 commits into
cloudfoundry:5.x.xfrom
ZPascal:fix-uaa-pagination-div-zero-5.x.x

Conversation

@ZPascal

@ZPascal ZPascal commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Port of #1472 to the 5.x.x branch.

UAA returns itemsPerPage: 0 when a list query has no results. PaginationUtils.requestUaaAdditionalPages divides by that value to work out the page count, so it fails with ArithmeticException: / by zero (e.g. in GroupsTest.unmapExternalGroupMappingsByGroupId).

Changes:

  • If all results fit in the first response (this covers the empty case), return it directly without requesting more pages.
  • If UAA reports itemsPerPage: 0 but there are still results, fail with a clear IllegalStateException instead of silently returning a partial list.
  • Unit tests for the empty case, a single page, and the itemsPerPage: 0 with results case.

UAA returns itemsPerPage=0 when a list query has no results. The page
count calculation divided by that value and failed with an
ArithmeticException, e.g. in GroupsTest.unmapExternalGroupMappingsByGroupId.
Return only the first response when there are no further pages.
Only return the first page early when there are no more results. If UAA
reports itemsPerPage=0 but still has results, emit an error instead of
completing with a partial list. Also skip the paging pipeline for single
page responses and drop null checks for attributes that are always set.

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.

1 participant