Skip to content

fix: data element category option combos as valid mapping candidates - #1251

Open
xurxodev wants to merge 2 commits into
developmentfrom
fix/program-indicator-coc-mapping-to-data-element
Open

fix: data element category option combos as valid mapping candidates#1251
xurxodev wants to merge 2 commits into
developmentfrom
fix/program-indicator-coc-mapping-to-data-element

Conversation

@xurxodev

@xurxodev xurxodev commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

📌 References

  • Issue: Closes #?

📝 Implementation

  • Restore the "dataElements" case in GenericMappingUseCase.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.
  • This broke mapping a program indicator (or indicator) to a data element that has a real category combination (e.g. Gender: Male/Female): the "Category Option Combos" related-metadata mapping dialog only offered "default" instead of the destination data element's actual category option combos.
  • Added a unit test (GetValidMappingIdUseCase.spec.ts) covering that getValidMappingIds returns the destination data element's category option combos as valid candidates.
  • Verified manually that the original bug from [Fix] data elements warnings in mapping #907/[User feedback] Auto-map lists warnings even if there're no problems #1212 ("Auto-map lists warnings even if there're no problem") does not reappear: a later fix (falling back to the destination's real default COC instead of EXCLUDED_KEY in autoMapCollection) already prevents the false-conflict warning independently of this case.

📹 Screenshots/Screen capture

🔥 Is there anything the reviewer should know to test it?

  • Map a program indicator to a data element that has a non-default category combination (e.g. Gender) in the destination instance.
  • Open "Related metadata mapping" > "Category Option Combos" for that row.
  • The picker should now list the destination data element's real category option combos (e.g. Male/Female), not just "default".

📑 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

…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".
@xurxodev xurxodev changed the title fix: restore data element category option combos as valid mapping candidates fix: data element category option combos as valid mapping candidates Jul 7, 2026
@bundlemon

bundlemon Bot commented Jul 7, 2026

Copy link
Copy Markdown

BundleMon

No change in files bundle size

Groups updated (1)
Status Path Size Limits
Build Folder
./**/*
2.67MB (+85B 0%) +20%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@xurxodev
xurxodev requested a review from anagperal July 7, 2026 10:15

@anagperal anagperal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Image

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

@xurxodev

xurxodev commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Hi @anagperal, I tried to reproduce the same issue you found but wasn't able to.

Screenshot 2026-07-07 at 16 44 46

Could you confirm the exact steps you followed? Specifically:

  • Local instance URL:
  • Destination instance URL:
  • Mapping between PI UID and DE UID in destination: (which program indicator and which destination data element did you map)
  • Mapping between default and COC in destination: (in the Category Option Combos / Attribute Option Combos wizard step, what did you map the origin's "default" row to)
  • Any additional steps or order of actions until you reproduce the warning

@anagperal

anagperal commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@xurxodev

Hi @anagperal, I tried to reproduce the same issue you found but wasn't able to.

Screenshot 2026-07-07 at 16 44 46 Could you confirm the exact steps you followed? Specifically:

test-FEM-dataelement-and-dataset.json

  • Mapping between default and COC in destination: (in the Category Option Combos / Attribute Option Combos wizard step, what did you map the origin's "default" row to)
    COC: HllvX50cXC0 (default) --> qk6n4eMAdtK (Female)
    Attribute Option Combo: HllvX50cXC0 (default) --> qk6n4eMAdtK (Female)

  • Any additional steps or order of actions until you reproduce the warning

Video mapping PI BMI male to a clone of DE test Fem (test Male HQMG7okGWam )

Screencast.from.2026-07-07.17-08-13.webm

@anagperal

Copy link
Copy Markdown
Contributor

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.
@xurxodev

xurxodev commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@anagperal ready

@anagperal anagperal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@xurxodev thanks!! all ok

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