Skip to content

Support DHIS2 2.43 - #1253

Open
xurxodev wants to merge 3 commits into
developmentfrom
feat/support_2_43
Open

Support DHIS2 2.43#1253
xurxodev wants to merge 3 commits into
developmentfrom
feat/support_2_43

Conversation

@xurxodev

@xurxodev xurxodev commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

📌 References

📝 Implementation

DHIS2 tightened validation on two /tracker/* GET endpoints across recent server versions, in each case requiring a parameter that used to be optional/omittable. Both were found via real HAR captures against play.im.dhis2.org/stable-2-43-0-1 and confirmed empirically against 2.40/2.41/2.42/2.43 play instances.

  • /tracker/events (2.43+): requires program alongside programStage; previously only programStage was sent. Fix threads {program, programStage} pairs end-to-end (reusing the existing ProgramStageRef type) instead of bare programStage strings, touching EventsRepository, ListEventsUseCase, EventsD2ApiRepository, EventsPayloadBuilder, EventsSelectionStep.tsx, and MSFHomePagePresenter.ts. Sending program alongside programStage is a no-op on 2.40/2.41/2.42 and required on 2.43+, so no version check is needed here.
  • /tracker/trackedEntities cross-program lookup by TEI ids (2.42+): the deprecated singular trackedEntity param alone now fails with E1003. Unlike the events fix, there's no single param choice that works on every version — <=2.40 only supports the singular trackedEntity (the plural doesn't filter by id yet), 2.41 accepts either but rejects both together, and >=2.42 requires the plural trackedEntities. Fixed in TEID2ApiRepository.getTEIsById() by branching on targetInstance.apiVersion.
  • /api/dataValueSets (2.43+): on GET, when the query filters by a single orgUnit, DHIS2 2.43 stops repeating orgUnit on each returned dataValue and sets it only once at the response root instead. AggregatedD2ApiRepository.getAggregated() blindly destructured orgUnit off each item, so the subsequent sync POST carried an empty orgUnit on every dataValue in that case. Fixed with a fallback (orgUnit ?? data.orgUnit) — the per-item field is still used whenever DHIS2 does send it, so no version check is needed.

📹 Screenshots/Screen capture

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

  • Added a regression assertion to the /tracker/events mock in sync-events.spec.ts that fails if program is missing from the request.
  • All three fixes were empirically verified against real play.im.dhis2.org instances (2.40.12, 2.41.9, 2.42.5.1, 2.43.0.1) by hitting the endpoints directly with curl, not just via mocked tests. For the orgUnit fix specifically: verified via POST/GET round-trip with real test data on single- and multi-orgUnit queries on 2.43 to nail the boundary, then cleaned up the test data values afterward.
  • Full suite green, tsc --noEmit clean.

📑 Others

  • No changes in the GUI library or D2 Api.

xurxodev added 2 commits July 9, 2026 10:27
DHIS2 2.43 requires `program` in /tracker/events GET requests when filtering
by programStage; omitting it (previously only programStage was sent) fails
with a 400 Bad Request. Threads {program, programStage} pairs end-to-end via
the existing ProgramStageRef type instead of bare programStage strings.
…ogram lookup

DHIS2 tightened /tracker/trackedEntities GET validation inconsistently across
versions: <=2.40 requires the deprecated singular `trackedEntity` (the plural
`trackedEntities` doesn't filter by id yet), 2.41 accepts either but rejects
both together, and >=2.42 requires the plural `trackedEntities` (E1003 if only
`trackedEntity` is sent). No single param works on all versions, so
getTEIsById() now picks the param based on targetInstance.apiVersion.
@xurxodev xurxodev changed the title fix: support DHIS2 2.42/2.43 tracker API required-param changes Support DHIS2 2.43 Jul 9, 2026
@bundlemon

bundlemon Bot commented Jul 9, 2026

Copy link
Copy Markdown

BundleMon

No change in files bundle size

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

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

….43 omits it per dataValue

DHIS2 2.43 leaves out the per-item orgUnit in GET /api/dataValueSets
responses when the query filters by a single orgUnit, setting it only
once at the response root instead. This caused the sync's POST payload
to carry an empty orgUnit on every dataValue in that case.
@xurxodev
xurxodev marked this pull request as ready for review July 13, 2026 05:20
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.

1 participant