-
Notifications
You must be signed in to change notification settings - Fork 35
fix: [DHIS2-20352] Capture app fails to load when DE or TEA referenced in indicator is missing #4391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: [DHIS2-20352] Capture app fails to load when DE or TEA referenced in indicator is missing #4391
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a runtime error in the Capture app when program indicators reference missing data elements or tracked entity attributes. The fix adds null safety checks and validation to prevent the app from failing to load due to misconfigured indicators.
Key Changes:
- Added null checks in
getDirectAddressedVariableto handle missing data elements and attributes - Added validation in
buildIndicatorRuleAndVariablesto detect and skip indicators with invalid references - Enhanced logging to report configuration errors for problematic indicators
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...ules/capture-core/metaDataMemoryStoreBuilders/programs/getRulesAndVariablesFromIndicators.ts
Outdated
Show resolved
Hide resolved
simonadomnisoru
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the false assumption in the original code is that programData will contain all data elements and attributes referenced in the PI expressions. The solution is to ignore any PI which violates this assumption.
I'm uncertain about the condition variables.length < expectedVariables. Looking closely at the edited file, I'm starting to think ìt might be easier and more accurate to throw an error in getDirectAddressedVariable if a DE or attribute is missing, and wrap the call to getVariables in a try-catch block.
|
🚀 Deployed on https://deploy-preview-4391.capture.netlify.dhis2.org |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ules/capture-core/metaDataMemoryStoreBuilders/programs/getRulesAndVariablesFromIndicators.ts
Outdated
Show resolved
Hide resolved
...ules/capture-core/metaDataMemoryStoreBuilders/programs/getRulesAndVariablesFromIndicators.ts
Outdated
Show resolved
Hide resolved
|
superskip
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
## [104.6.5](v104.6.4...v104.6.5) (2025-11-12) ### Bug Fixes * [DHIS2-20352] Capture app fails to load when DE or TEA referenced in indicator is missing ([#4391](#4391)) ([e9fa7c2](e9fa7c2))
|
🎉 This PR is included in version 104.6.5 🎉 The release is available on:
Your semantic-release bot 📦🚀 |



DHIS2-20352
This pull request prevents runtime errors and improves logging for misconfigured indicators.
Added null checks for data elements and attributes in
getDirectAddressedVariableto prevent undefined property access and throw an error for missing references.Added validation in
buildIndicatorRuleAndVariablesto log an error and skip program indicators with missing references.