Skip to content

[fix]: Scheduler failing on DHIS2 2.43 (userCredentials removed from /me)#1248

Open
deeonwuli wants to merge 2 commits into
developmentfrom
fix/scheduler-in-2.43
Open

[fix]: Scheduler failing on DHIS2 2.43 (userCredentials removed from /me)#1248
deeonwuli wants to merge 2 commits into
developmentfrom
fix/scheduler-in-2.43

Conversation

@deeonwuli

Copy link
Copy Markdown
Contributor

📌 References

📝 Implementation

Root cause: DHIS2 version 2.43 removed the userCredentials wrapper from /api/me; username/userRoles are now top-level. Code reading currentUser.userCredentials.userRoles/.username threw Cannot read properties of undefined (reading 'userRoles'). In the scheduler this surfaced only as [ERROR] scheduler - {} because the catch blocks serialized the error with JSON.stringify(error), which returns {} for Error objects.

  • Added a getErrorMessage helper (src/utils/error.ts) and used it in the scheduler catch blocks (cli.ts, SchedulerCLI.ts) so errors log with their real message/stack instead of {}. Also applied it to previously swallowed dataStore read errors (StorageDataStoreClient).
  • Updated all current-user (/me) reads to support both pre-2.43 and 2.43+ shapes via a fallback (userCredentials?.x ?? x): permissions.ts (getUserInfo, getUserRoles), UserD2ApiRepository.getCurrent, GenericSyncUseCase, and the package list/import components (routed through the user use case).

📹 Screenshots/Screen capture

🔥 Is there anything the reviewer should know to test it?

  • Run the scheduler against a DHIS2 2.43 instance that has a scheduler-enabled sync rule. Before this change it fails right after "Loading synchronization rules from remote server"; after, rules load and schedule normally.

#869dqwtvv

@bundlemon

bundlemon Bot commented Jun 22, 2026

Copy link
Copy Markdown

BundleMon

No change in files bundle size

Groups updated (1)
Status Path Size Limits
Build Folder
./**/*
2.67MB (+184B +0.01%) +20%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

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