Skip to content

Conversation

@uneq95
Copy link
Contributor

@uneq95 uneq95 commented Jan 27, 2026

The do-while pagination pattern was incorrectly checking hasNextPage() after calling getNextPage(), causing the last page of results to be skipped.

Affected functions:

  • getConnectionEnabledClients() in connections.ts
  • role permissions listing in roles.ts
  • getOrganizationEnabledConnections() in organizations.ts
  • getOrganizationClientGrants() in organizations.ts
  • getAllOrganizationDiscoveryDomains() in organizations.ts
  • getAllFlowConnections() in flowVaultConnections.ts

Added multi-page pagination tests to verify the fix.

Fixes #1272

🔧 Changes

📚 References

🔬 Testing

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@uneq95 uneq95 requested a review from a team as a code owner January 27, 2026 10:16
@uneq95
Copy link
Contributor Author

uneq95 commented Jan 27, 2026

Looks like the E2E test failures (test:e2e:node-module) are pre-existing and unrelated to this PR. The Nock recordings don't match the current client payload structure (specifically cross_origin_authentication field). This PR only modifies pagination logic in connections.ts, flowVaultConnections.ts, organizations.ts, and roles.ts - none of which affect the client handler. The unit tests for the affected handlers all pass.

@uneq95
Copy link
Contributor Author

uneq95 commented Jan 27, 2026

973 passing (13m)
1 pending
1 failing

  1. #YAML context actions
    should process actions:
    Error: Timeout of 20000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/home/circleci/repo/test/context/yaml/actions.test.js)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)

The tests that I added are running fine. Not yet sure what the above failure means as I am very new to the project.

@kushalshit27
Copy link
Contributor

Hi, @uneq95 ,
Thank you for submitting this PR!

I have a small suggestion to make it even better:

Example:

// Process first page outside the loop
allEnabledClients.push(...enabledClients.data);

// Fetch remaining pages
while (enabledClients.hasNextPage()) {
  enabledClients = await enabledClients.getNextPage();
  allEnabledClients.push(...enabledClients.data);
}
  • The while approach would be cleaner for processing than 'do-while'. Let us know if this approach works for you.
  • We can take care of E2E test failures

Let me know if you have any questions. Looking forward to your updates!

@kushalshit27 kushalshit27 marked this pull request as draft January 27, 2026 11:21
The do-while pagination pattern was incorrectly checking hasNextPage()
after calling getNextPage(), causing the last page of results to be
skipped.

Affected functions:
- getConnectionEnabledClients() in connections.ts
- role permissions listing in roles.ts
- getOrganizationEnabledConnections() in organizations.ts
- getOrganizationClientGrants() in organizations.ts
- getAllOrganizationDiscoveryDomains() in organizations.ts
- getAllFlowConnections() in flowVaultConnections.ts

Added multi-page pagination tests to verify the fix.

Fixes auth0#1272
@uneq95 uneq95 force-pushed the fix/pagination-bug-enabled-clients branch from 2dae5aa to dcb7841 Compare January 27, 2026 12:02
@uneq95 uneq95 marked this pull request as ready for review January 27, 2026 12:38
@kushalshit27 kushalshit27 merged commit 2db7d16 into auth0:master Jan 28, 2026
5 of 6 checks passed
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.

Pagination bug in getConnectionEnabledClients causes last page of enabled_clients to be skipped during export

2 participants