fix: Load tracked entity attributes for event-only imports in rule engine validation [DHIS2-21961] - #24870
Open
ameenhere wants to merge 1 commit into
Open
fix: Load tracked entity attributes for event-only imports in rule engine validation [DHIS2-21961] #24870ameenhere wants to merge 1 commit into
ameenhere wants to merge 1 commit into
Conversation
…eheat for correct program rule evaluation on event completion
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Program rules referencing tracked entity attributes (TEAs) evaluated them as
null when the import payload contained only events — the payload the Capture
app sends when completing an event. This caused ERROR_ON_COMPLETE and
assign-when-empty rules to fire incorrectly, blocking event completion
(regression from 2.40, introduced with the new rule engine integration).
Cause
Tracked entities are only preheated when referenced by the payload. Event-only
payloads reference no tracked entity, so
getAttributesfound nothing in thepreheat and built the
RuleEnrollmentwith an empty attribute list.Fix
When the tracked entity is not in the preheat, fall back to the tracked entity
of the preheated saved enrollment, which already carries its attribute values.
Attribute loading is still skipped when rules don't reference TEAs.
Tests
Integration tests covering: TEA value visible to rules on event-only import,
completed event passing an on-complete rule when the TEA has a value, and the
inverse control (rule still fires when the TEA is empty).
Jira: https://dhis2.atlassian.net/browse/DHIS2-21961
Obviously AI-assisted