Skip to content

Conversation

@RajPrakash681
Copy link
Contributor

@RajPrakash681 RajPrakash681 commented Nov 20, 2025

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. Ensure your PR title includes a conventional commit label (such as feat, fix, or chore, among others). See existing PR titles for inspiration.

If applicable

  • My work is based on designs, which are linked or shown either in the Jira ticket or the description below.
  • My work includes tests or is validated by existing tests.
  • I have updated the esm-framework mock to reflect any API changes I have made.

Summary

This PR fixes a pagination issue in the backend module fetching mechanism. Previously, the fetchInstalledBackendModules() and fetchAllBackendModules() functions only retrieved the first page of results (50 modules by default), missing any additional modules when pagination was present.

The fix implements proper pagination handling by:

  • Following the data.next field in API responses to fetch subsequent pages
  • Including proper URL normalization for relative, absolute, and fully-qualified next URLs
  • Adding comprehensive JSDoc documentation and inline comments
  • Implementing robust error handling with descriptive error messages

Changes Made:

  1. packages/shell/esm-app-shell/src/optionaldeps.ts: Updated fetchAllBackendModules() to fetch all paginated results for optional backend dependencies
  2. packages/apps/esm-implementer-tools-app/src/backend-dependencies/openmrs-backend-dependencies.ts: Updated fetchInstalledBackendModules() to fetch all paginated results for dependency checking

Technical Details:

  • The OpenMRS REST API returns paginated results with a next field pointing to the next page
  • The implementation loops through all pages until next is null or the safety limit is reached
  • If the limit is reached, a warning is logged indicating there may be more data available

Screenshots

N/A - This is a backend logic fix with no UI changes.

Related Issue

Others

@RajPrakash681
Copy link
Contributor Author

@chibongho implemented the same that i shared on https://openmrs.atlassian.net/browse/O3-4646 please have a look and guide if it needs anything else!

@denniskigen denniskigen requested a review from ibacher November 25, 2025 21:57
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