Skip to content

(fix) O3-4646: Register optional dependency feature flags for backend modules on every page - #2038

Open
gargnaitik wants to merge 1 commit into
openmrs:mainfrom
gargnaitik:fix/O3-4646-optional-deps-all-modules
Open

gargnaitik wants to merge 1 commit into
openmrs:mainfrom
gargnaitik:fix/O3-4646-optional-deps-all-modules

Conversation

@gargnaitik

Copy link
Copy Markdown

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work is based on designs, which are linked or shown either in the Jira ticket or the description below. (See also: Styleguide)
  • My work includes tests or is validated by existing tests.
  • I have updated the esm-framework and storybook mocks (mock.tsx, mock-jest.tsx, and storybook mocks) to reflect any API changes.

Summary

At startup the app shell fetches the installed backend modules to turn on the feature flags that frontend modules declare for their optional backend dependencies. setupOptionalDependencies read only the first page of /module, which the REST module pages at webservices.rest.maxResultsDefault (50 by default). An optional dependency on a backend module listed on a later page never turned on its feature flag, so the features behind it stayed hidden without any error.

setupOptionalDependencies now loads the module list with openmrsFetchAll (#2019), which follows the next links.

openmrsFetchAll rejects if any page fails, so if a later page fails to load, no flags are set, including ones for modules on the first page. Previously a failed request also set no flags, so this keeps the existing all-or-nothing behaviour.

The implementer tools part of O3-4646 was already fixed by #1463, so this PR completes the ticket.

Screenshots

No UI change.

Related Issue

https://openmrs.atlassian.net/browse/O3-4646

Other

optionaldeps.ts had no tests. optionaldeps.test.ts runs the real openmrsFetchAll against a mocked openmrsFetch and covers:

  • a module on the second page gets its flag (fails without this change)
  • a module on the first page gets its flag
  • a version that doesn't satisfy the requirement gets no flag
  • a failed page sets no flags
  • the module list isn't requested when no frontend module has an optional dependency

… modules on every page

The app shell read only the first page of the backend module list, so an
optional dependency on a module listed on a later page never turned on its
feature flag. Load every page with openmrsFetchAll and add tests.
@changeset-bot

changeset-bot Bot commented Dec 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 32713bc

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

@greptile-apps

greptile-apps Bot commented Dec 1, 2026

Copy link
Copy Markdown

security Security Review

This PR appears safe to merge from a security standpoint.

What was checked
  • The module list is still fetched only after the session loads and session.authenticated is true, so no unauthenticated caller reaches this code.
  • openmrsFetchAll strips the origin from every next link and re-anchors it to the first page's origin, so the paged fetches cannot be steered to another origin with the user's credentials.
  • A failed or malformed page leaves the feature flags unset (the .catch swallows the error), which only hides UI; the backend still enforces access control.
  • A malformed backend module version cannot crash the page: satisfies returns false for unparseable versions and any throw is swallowed by the existing catch.
  • The new test file only mocks openmrsFetch and touches no real security boundary.

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · This PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

No actionable issues found.

  • Optional backend flags now work beyond the first module page.

Reviews (1) · Last reviewed commit: "(fix) O3-4646: Register optional depende..." · Reviewed by Greptile

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