Skip to content

Conversation

@zubaira
Copy link
Contributor

@zubaira zubaira commented Sep 11, 2025

https://dhis2.atlassian.net/browse/DHIS2-19426
PR implements d2:inUserGroup function for program rule.
d2:inUserGroup('UYXOT4A3SA') should return true if the current user is a member of this group "UYXOT4A3SA"

@sonarqubecloud
Copy link

@zubaira zubaira requested review from ameenhere, enricocolasante, jbee and vgarciabnz and removed request for jbee September 11, 2025 09:37
Copy link
Collaborator

@jbee jbee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

(but I have forgotten a lot of details about the code 😂 )

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this related to the rest of the PR? Seems the change from "USER_ROLES" to "USER" is another thing?

Copy link
Contributor Author

@zubaira zubaira Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems more aligned with the current update. The USER keyword was already being used for user roles, and now that we’re introducing USER_GROUPS, it makes sense to rename USER to USER_ROLES for better consistency and clarity.

@zubaira zubaira merged commit c6e84ae into main Sep 15, 2025
4 checks passed
NamedFunction.d2_hasUserRole -> functions.d2_hasUserRole(
evalToString(fn.child(0)),
data.supplementaryValues["USER"])
data.supplementaryValues["USER_ROLES"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will introduce a breaking change in the integrations. In the case of Android, this supplementaryValues property is passed by the Android app and it has the key USER (check this line in the Android app). I guess it would happen the same for the backend, @enricocolasante?

This change must be warned in the release notes. Or change, at least, the minor digit of the version instead of the patch one.

@jbee @zubaira

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clients will have to update to support USER_GROUPS this could also be the right opportunity to introduce the breaking change of renaming USER to USER_ROLES for better consistency. But if we all agree otherwise, then we can revert this change.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, we should add some warn somewhere and change the minor digit of the version.
I would also take the opportunity to make the supplementaryValues more explicit and structured and not rely on strings, so the breaking change would fail at compilation and it would be easier for the client fix it.
With the current change, rule-engine will continue to work but some strange behavior will happen around users and it is not really easy for the client to discover and understanding what is happening

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.

5 participants