Skip to content

fix: show dataset and org unit names (not UIDs) in autocomplete-compute error alerts - #180

Open
Ramon-Jimenez wants to merge 2 commits into
developmentfrom
fix/autocomplete-error-names-uids
Open

Ramon-Jimenez wants to merge 2 commits into
developmentfrom
fix/autocomplete-error-names-uids

Conversation

@Ramon-Jimenez

@Ramon-Jimenez Ramon-Jimenez commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

ClickUp

Closes CU-869du4j73

Problem

In the NHWA Auto-complete compute report (standard + subnational variants), the error banner shown after a Fix all run displayed raw DHIS2 import-conflict messages with UIDs instead of names, e.g.:

ERROR: E7642: Data already approved for data set: Tu81BTLUuCT … org unit: e9IoKRAkYLO

Client reported these used to show readable names.

Root cause

These messages are produced verbatim by the DHIS2 backend (conflict.value). The only client-side beautification, replaceOrgUnitIdByName in AlertStatsErrors, had two long-standing gaps:

  • Its regex matched organisation unit:, but the actual message wording is org unit: → never matched.
  • It never resolved the data set name at all.

(The trigger for the change was almost certainly a server-side conflict-message format change; this fix makes the app robust regardless.)

Fix

  • Replace the org-unit-only regex with a generic replaceIdsByNames that swaps every backtick-wrapped UID for its name, independent of the surrounding label wording.
  • Resolve both org units (already loaded) and the app's configured data sets (config.dataSets).
  • Wire dataSets through to AlertStatsErrors from the auto-complete-compute report (covers the subnational variant too — same shared component) and the fix-totals report.

Scope

  • AlertStatsErrors.tsx — generic UID→name resolver
  • NHWAAutoCompleteCompute.tsx — passes dataSets (used by both standard and subnational variants)
  • NHWAFixTotals.tsx — passes dataSets

Testing

  • tsc --noEmit clean, eslint clean, prettier-formatted.

🤖 Generated with Claude Code

… alerts

DHIS2 import-conflict messages (e.g. E7642) reference metadata by UID. The
existing replacement only targeted org units via a regex matching
"organisation unit:", which never matched the actual "org unit:" wording, and
it never resolved the data set name at all.

Replace UIDs generically: swap every backtick-wrapped UID for its name using
the org units already loaded plus the app's configured data sets, independent
of the surrounding label wording. Wire dataSets through to AlertStatsErrors
from both the auto-complete-compute (incl. subnational variant) and
fix-totals reports.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Ramon-Jimenez
Ramon-Jimenez requested a review from eperedo June 22, 2026 09:18

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

it works, just a minor observation to avoid duplicating a type.

// DHIS2 import conflict messages reference metadata by UID (e.g. ``data set: `Tu81BTLUuCT` ...
// org unit: `e9IoKRAkYLO```). Replace every backtick-wrapped UID we know about with its name,
// regardless of the surrounding label wording (which varies between DHIS2 versions).
function replaceIdsByNames(message: string, items: Array<{ id: string; name: string }>): string {

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.

we can use NamedRef[] for items instead of array<{}>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call — done in 96fff74. Switched replaceIdsByNames to take NamedRef[]; OrgUnit satisfies it so the [...orgUnits, ...dataSets] spread still typechecks.

Address review feedback: NamedRef[] is the existing shared type for
{ id, name } refs, clearer than an inline object array.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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