Uh oh!
There was an error while loading. Please reload this page.
fixes three related pagination bugs in the command's org user fetch … - #234
Conversation
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
Consider reviewing these vulnerabilities when fixes become available. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
Consider reviewing these vulnerabilities when fixes become available. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Port of fix/DX-3943 to v1-dev. Fixes three related pagination bugs in the
export-to-csvcommand's org user fetch logic.Problem
Bug 1 — Org owners only got the first page of users
getOrgUsershad a special branch foris_owner === truethat calledgetInvitations()with no parameters and resolved immediately. Ownerswith more than
config.limitusers silently received a truncated list.Bug 2 — Wrong access-denied guard
The guard for non-owners checked
!organization.getInvitations(whethera method existed on the object) instead of
!organization.is_owner.This was always falsy and the check was effectively dead.
Bug 3 — Last page items dropped in pagination loop
getUsersstopped paginating whenusers.items.length === 0. But theactual final page (a partial page with fewer items than the limit) was
fetched, its items ignored, and then an extra empty-page round-trip was
made before stopping.
Changes
src/utils/api-client.tsis_owner === trueearly-exit branch; owners now gothrough the same paginated
getUserspath as admins.!organization.getInvitations→!organization.is_owner.getUsersfrom!users.items.length→users.items.length < params.limit, and correctly appends thepartial last page's items before returning.
limit: 100→limit: config.limit.test/unit/utils/api-client.test.tsgetOrgUserstest suite with three cases: pagination forowners, pagination for admins, and access-denied rejection.
Test plan
getOrgUsersreturns all pages for org owners (not just page 1)getOrgUsersreturns all pages for org adminsgetOrgUsersrejects withERROR_ADMIN_ACCESS_DENIEDfor users with neither rolenpm run test:unit— all api-client tests pass