Skip to content

fix: Handle ProgramRuleAction without a ProgramRule when importing [DHIS2-13920] - #24979

Open
david-mackessy wants to merge 6 commits into
masterfrom
DHIS2-13920
Open

fix: Handle ProgramRuleAction without a ProgramRule when importing [DHIS2-13920]#24979
david-mackessy wants to merge 6 commits into
masterfrom
DHIS2-13920

Conversation

@david-mackessy

@david-mackessy david-mackessy commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Issue

Importing a ProgramRuleAction with no ref to a ProgramRule results in NullPointerException & 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 ProgramRuleAction with no ref to a ProgramRule. Causes a NPE and abruptly stops the import job.

Fix

Check that a ProgramRuleAction has a ProgramRule before continuing the import flow.
Report an error if there is no ProgramRule attached, which allows the import job to continue.

Testing

Added tests that check importing a payload with a ProgramRuleAction without a ProgramRule ref.

  • atomicMode=ALL -> no objects imported and object report contains error detailing the missing ref issue
  • atomicMode=NONE -> valid objects still imported and invalid ProgramRuleAction ignored with an error report

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"),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

used the next available error code

@david-mackessy
david-mackessy marked this pull request as ready for review August 27, 2026 14:09
@david-mackessy david-mackessy changed the title Dhis2 13920 fix: Handle ProgramRuleAction without a ProgramRule when importing [DHIS2-13920] Aug 27, 2026
@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants