fix: data element category option combos as valid mapping candidates - #1251
fix: data element category option combos as valid mapping candidates#1251xurxodev wants to merge 2 commits into
Conversation
…didates getCategoryOptionCombos() dropped its "dataElements" case in a4aebc5 (PR #907), which was meant to stop generating a spurious inner mapping when a data element is the *origin* of an aggregated mapping. As a side effect it also broke the destination side: mapping a program indicator (or indicator) to a data element no longer offered the destination data element's real category option combos in the mapping dialog, collapsing the picker to just "default".
BundleMonNo change in files bundle size Groups updated (1)
Final result: ✅ View report in BundleMon website ➡️ |
anagperal
left a comment
There was a problem hiding this comment.
thanks @xurxodev ! This fix works, but while testing this change I mapped a program indicator to a data element with a non-default category combination (Gender) in the destination. I completed both wizard steps — I mapped the origin default to the corresponding destination category option combo in Category Option Combos and in Attribute Option Combos — but the row still shows the "Mapping has errors" warning.
Why it happens
The Mapping has errors badge fires on conflicts || childrenConflicts (MappingTable.tsx:633), and conflicts is set as candidate.mappedId === EXCLUDED_KEY in autoMapCollection (GenericMappingUseCase.ts:280). The origin's default category option has no counterpart in a data element with a real category combo (Gender → Male/Female), so it falls back to EXCLUDED_KEY ("DISABLED") → conflicts: true in childrenConflicts
Suggested fix (same rationale as 9e2072c2): pass a destination-default fallback to the categoryOptions collection so the origin default option maps to the destination default instead of EXCLUDED_KEY
|
Hi @anagperal, I tried to reproduce the same issue you found but wasn't able to.
Could you confirm the exact steps you followed? Specifically:
|
test-FEM-dataelement-and-dataset.json
Video mapping PI BMI male to a clone of DE test Fem (test Male HQMG7okGWam ) Screencast.from.2026-07-07.17-08-13.webm |
|
DHIS2 Issue found while testing this PR : https://dhis2.atlassian.net/browse/DHIS2-21777 |
…e conflict Same rationale as 9e2072c for category option combos: a destination data element with a real category combo (e.g. Gender) doesn't offer "default" as a candidate, so the origin's default category option never matches and falls back to EXCLUDED_KEY, causing a false "Mapping has errors" warning.
|
@anagperal ready |


📌 References
📝 Implementation
"dataElements"case inGenericMappingUseCase.getCategoryOptionCombos(), which was removed in [Fix] data elements warnings in mapping #907 (commit a4aebc5). That PR intended to stop generating a spurious inner category-option-combo mapping when a data element is the origin of an aggregated mapping (to avoid false conflict warnings on auto-map). As a side effect it also removed the ability to resolve category option combos when a data element is the destination of a mapping.GetValidMappingIdUseCase.spec.ts) covering thatgetValidMappingIdsreturns the destination data element's category option combos as valid candidates.EXCLUDED_KEYinautoMapCollection) already prevents the false-conflict warning independently of this case.📹 Screenshots/Screen capture
🔥 Is there anything the reviewer should know to test it?
📑 Others
Any change in the GUI library? If so, what branch/PR? No
Any change in the D2 Api? If so, what branch/PR? No