Skip to content

fix: Load tracked entity attributes for event-only imports in rule engine validation [DHIS2-21961] - #24870

Open
ameenhere wants to merge 1 commit into
2.42from
DHIS2-21961_2.42
Open

fix: Load tracked entity attributes for event-only imports in rule engine validation [DHIS2-21961] #24870
ameenhere wants to merge 1 commit into
2.42from
DHIS2-21961_2.42

Conversation

@ameenhere

@ameenhere ameenhere commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

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 getAttributes found nothing in the
preheat and built the RuleEnrollment with 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

…eheat for correct program rule evaluation on event completion
@sonarqubecloud

Copy link
Copy Markdown

@ameenhere ameenhere changed the title fix: DHIS2-21961 Add fallback to get TrackedEntity from enrollment preheat for correct program rule evaluation on event completion fix: Load tracked entity attributes for event-only imports in rule engine validation [DHIS2-21961] Aug 14, 2026
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