Skip to content

fix: register program metadata for tracked entity visualizations - #345

Open
HendrikThePendric wants to merge 2 commits into
masterfrom
fix/org-unit-metadata-missing
Open

fix: register program metadata for tracked entity visualizations#345
HendrikThePendric wants to merge 2 commits into
masterfrom
fix/org-unit-metadata-missing

Conversation

@HendrikThePendric

@HendrikThePendric HendrikThePendric commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Implements DHIS2-21990

Description

Loading a saved tracked entity visualization crashes with missing metadata:

No context metadata found for dimension with compound ID "IpHINAT79UW.enrollmentOu"

extractProgramDimensionsMetadata returned early for TRACKED_ENTITY_INSTANCE, so the program was never added to the metadata store. But getFixedDimensionOverrides has no such guard and still builds dimensions like IpHINAT79UW.enrollmentOu from the same program list.

The store needs the program. IpHINAT79UW.enrollmentOu and nEenWmSyUEp.enrollmentOu look 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_INSTANCE only, 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 the getFixedDimensionOverrides that produces the program-prefixed IDs, which is where the bug starts.


Quality checklist

  • Dashboard tested N/A
  • Cypress and/or Jest tests added/updated
  • Docs added N/A
  • d2-ci dependency replaced N/A

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>
@dhis2-bot

Copy link
Copy Markdown
Contributor

🚀 Deployed on https://pr-345.event-visualizer.netlify.dhis2.org

@dhis2-bot
dhis2-bot temporarily deployed to netlify August 18, 2026 12:31 Inactive
@HendrikThePendric HendrikThePendric self-assigned this Aug 18, 2026
@dhis2-bot
dhis2-bot temporarily deployed to netlify August 18, 2026 14:16 Inactive
@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.

3 participants