[fix]: Scheduler failing on DHIS2 2.43 (userCredentials removed from /me) - #1248
[fix]: Scheduler failing on DHIS2 2.43 (userCredentials removed from /me)#1248deeonwuli wants to merge 2 commits into
Conversation
BundleMonNo change in files bundle size Groups updated (1)
Final result: ✅ View report in BundleMon website ➡️ |
|
@idelcano could you please provide a functional review of that one? |
|
Hi @deeonwuli! Heads up that this branch is behind development and conflicts with the d2-api upgrade that merged last week (#1064), which touched the same userCredentials handling. Related PR: #1064 Could you resolve conflicts and give it a quick check on 2.43 before I finalize? Worth a look at #1064 first, there's real overlap, so the scope here likely narrows to the logging improvement. 🙏 |
xurxodev
left a comment
There was a problem hiding this comment.
@deeonwuli @MiquelAdell @gqcorneby
I think this PR is not necessary and it can be closed. The user credentials is a 2.42 problem not 2.43 and it was solved by @MatiasArriola in this PR #1064
|
thank you all for your comments. |
The diff is outdated since this branch needs to incorporate changes from development and resolve the conflicts (which are in fact the previous userCredentials implementation). So if we want to keep part of this PR, it would stop being "Scheduler failing on DHIS2 2.43 (userCredentials removed from /me)" and become something like "Improve error reporting in Scheduler" |
📌 References
📝 Implementation
Root cause: DHIS2 version 2.43 removed the
userCredentialswrapper from/api/me;username/userRolesare now top-level. Code readingcurrentUser.userCredentials.userRoles/.usernamethrewCannot read properties of undefined (reading 'userRoles'). In the scheduler this surfaced only as[ERROR] scheduler - {}because the catch blocks serialized the error withJSON.stringify(error), which returns{}forErrorobjects.getErrorMessagehelper (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)./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?
#869dqwtvv