fix: register program metadata for tracked entity visualizations - #345
Open
HendrikThePendric wants to merge 2 commits into
Open
fix: register program metadata for tracked entity visualizations#345HendrikThePendric wants to merge 2 commits into
HendrikThePendric wants to merge 2 commits into
Conversation
extractProgramDimensionsMetadata returned early for TRACKED_ENTITY_INSTANCE, so the program never reached the metadata store. getFixedDimensionOverrides has no such guard and still emits `programId.enrollmentOu` from the same programDimensions array, so the pipeline produced a compound ID prefixed with a program ID while withholding that program. Normalizing a 2-segment compound ID requires looking the prefix up to classify it as a program, stage or tracked entity type, so loading a tracker line list with an enrollment org unit in the layout threw "No context metadata found for dimension with compound ID". The guard was a leftover: the function used to also build program-prefixed time dimension IDs that were wrong for TRACKED_ENTITY_INSTANCE. That responsibility moved out, leaving only the program registration, which every output type needs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
🚀 Deployed on https://pr-345.event-visualizer.netlify.dhis2.org |
|
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.



Implements DHIS2-21990
Description
Loading a saved tracked entity visualization crashes with missing metadata:
extractProgramDimensionsMetadatareturned early forTRACKED_ENTITY_INSTANCE, so the program was never added to the metadata store. ButgetFixedDimensionOverrideshas no such guard and still builds dimensions likeIpHINAT79UW.enrollmentOufrom the same program list.The store needs the program.
IpHINAT79UW.enrollmentOuandnEenWmSyUEp.enrollmentOulook the same but mean different things — one is a program, the other a tracked entity type. The store tells them apart by looking up the first part. It wasn't there, so it threw. The throw is caught by the RTK query, so the whole visualization fails to load.This hits any tracked entity visualization whose layout references a program, whatever dimensions are in it — the fixed dimensions are generated per program and per stage, not per dimension actually in the layout.
I removed the guard so the program is registered for every output type.
The guard looks like a leftover of incorrectly implemented code. When the function was introduced in #75 it also built time-dimension keys that were program-prefixed for
TRACKED_ENTITY_INSTANCEonly, so maybe the guard was meant for that — but it was far too broad, since it also skipped registering the program. #190 moved the time-dimension generation out, leaving the guard with nothing to do and making it completely safe to remove. And the same PR also added thegetFixedDimensionOverridesthat produces the program-prefixed IDs, which is where the bug starts.Quality checklist