fix: Handle ProgramRuleAction without a ProgramRule when importing [DHIS2-13920] - #24979
Open
david-mackessy wants to merge 6 commits into
Open
fix: Handle ProgramRuleAction without a ProgramRule when importing [DHIS2-13920]#24979david-mackessy wants to merge 6 commits into
david-mackessy wants to merge 6 commits into
Conversation
david-mackessy
commented
Aug 27, 2026
| E4055("User needs to have at least one user role associated with it"), | ||
| E4050( | ||
| "One of DataElement, TrackedEntityAttribute or ProgramRuleVariable is required for program rule `{0}`"), | ||
| E4093("ProgramRuleAction `{0}` must reference a program rule"), |
Contributor
Author
There was a problem hiding this comment.
used the next available error code
david-mackessy
marked this pull request as ready for review
August 27, 2026 14:09
|
jbee
approved these changes
Aug 27, 2026
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.



Issue
Importing a
ProgramRuleActionwith no ref to aProgramRuleresults inNullPointerException& the import finishes unexpectedly.Import/Export app UI gets this response when importing async:
[ { "level": "ERROR", "category": "METADATA_IMPORT", "message": "Cannot invoke \"org.hisp.dhis.programrule.ProgramRule.getProgram()\" because \"rule\" is null", "completed": true, "uid": "iZ4eX8gGB0e", "id": "iZ4eX8gGB0e", "time": "2026-08-25T10:49:28.757" } ]Cause
Import payload has
ProgramRuleActionwith no ref to aProgramRule. Causes aNPEand abruptly stops the import job.Fix
Check that a
ProgramRuleActionhas aProgramRulebefore continuing the import flow.Report an error if there is no
ProgramRuleattached, which allows the import job to continue.Testing
Added tests that check importing a payload with a
ProgramRuleActionwithout aProgramRuleref.atomicMode=ALL-> no objects imported and object report contains error detailing the missing ref issueatomicMode=NONE-> valid objects still imported and invalidProgramRuleActionignored with an error report