RefApp 3.6.0 — stock management "Add user role scope" silently fails (frontend calls user-scopes, backend has no such resource)

Hi all,

On a fresh Reference Application 3.6.0 Docker distro (pinned TAG=3.6.0, so frontend/backend/gateway are all 3.6.0), I can’t save a user-role scope in Stock Management. The dialog closes without an error, but nothing is saved and the table stays empty.

Digging into it, the stock-management frontend calls:

GET/POST /openmrs/ws/rest/v1/stockmanagement/user-scopes

but the backend responds:

Unknown resource: v1/stockmanagement/user-scopes

The backend image bundles stockmanagement 3.0.0 (the latest release on GitHub). A code search of openmrs-module-stockmanagement returns zero matches for “user-scopes” anywhere in the module — the resource it actually exposes is userrolescope, which works fine when hit directly. So the 3.6.0 frontend appears to be calling an endpoint (user-scopes) that no released backend implements.

My question: which stockmanagement backend and esm-stock-management-app frontend versions are meant to be paired in RefApp 3.6.0? It looks like the bundled frontend is ahead of the bundled backend’s API. Is there a newer backend build I should be using, or should I pin the frontend module to an earlier version that still calls userrolescope?

Thanks!

Hi @jenspederrasmussen,

The current openmrs-esm-stock-management source uses /stockmanagement/userrolescope consistently — not /user-scopes. You can verify in stock-user-role-scopes.resource.ts.

If your network tab shows calls to /user-scopes, likely causes:

  1. Stale cached assets — Hard refresh (Ctrl+Shift+R) or restart the gateway container.

  2. Frontend version mismatch — Check which version is actually loaded by inspecting /openmrs/spa/importmap.json for the stock management entry. You can also check in the browser console:

    Object.keys(window.installedModules || {}).filter(m => m.includes('stock'))
    
  3. Distro packaging issue — If a pre-release build briefly used user-scopes before reverting, and the 3.6.0 distro pinned that version, that would explain the mismatch.

Workaround: Override the frontend module version in your import map to a known-good version, or raise this on openmrs-distro-referenceapplication if confirmed as a packaging bug.

Sharing the exact frontend version from your import map would help confirm the root cause.

Thanks Joseph.

Confirmed from importmap.json: the loaded frontend is @openmrs/esm-stock-management-app 3.2.0, while the backend bundles stockmanagement 3.0.0. So it’s a newer-frontend / older-backend mismatch — the 3.2.0 frontend calls /stockmanagement/user-scopes, which the 3.0.0 backend doesn’t implement (it has userrolescope). This is on a clean RefApp 3.6.0 distro (TAG=3.6.0), nothing custom on the stock-management versions. Looks like a distro packaging mismatch. Which frontend version would you recommend pinning to match backend 3.0.0 — or should this be raised on openmrs-distro-referenceapplication?

Best regards,

Jens Peder

The 3.0.0 stockmanagement backend uses /userscoperoles. The 3.2.0 frontend API calls /userscoperoles.

I can’t find the string user-scopes in the frontend code at all, never mind it making a request. It would be helpful if you can describe the steps you’re taking in the application that produces that failing request.

Sorry Folks I’m not up running yet. Let me try to describe in steps what I am doing.

  1. I use the Openmrs reference from docker version 3.7.0
  2. In the Locations Management in OpenMRS Legacy Admin I see a location Main Store and a Location Main Pharmacy
  3. I created a User Carl as a Provider with the following roles:
  4. I create two items in the stock Management tool:

  1. I created a Source:

  1. In User Role Scopes I define Carl

  1. in Operations I start a New Operation and selects Receipt to set the initial value on Ibuprofen

I define the initial stock for Ibuprofen:

and Pres Save

Pressing Next:

I select No

When I Press Complete: I get this:

Looking into the Browser Developer tool under Network:

The result is that I never gets out of the screen Submit/Complete and thereby don’t get the operation completed.

I observed, that the Payload has a destinationUuid: "c7ac3a68-fd4f-4874-bb26-8fde27b54a9a When I look in the Openmrs Location Management under Main Store the Uuid for that location is:19dbe2c0-289d-11ed-bdcb-507b9dea1806

I may be a wild guess but I assumed that the two Uuids should be the same.

Can you help me to clarify what I am doing wrong and why I can’t get the Stockmanagement tool to work. Best Regards, Jens Peder