Skip to content

chore(types): tighten organisation unit name retrieval - #4724

Open
daryn-brown wants to merge 2 commits into
dhis2:masterfrom
daryn-brown:daryn-brown-capture-app-quality-fix
Open

chore(types): tighten organisation unit name retrieval#4724
daryn-brown wants to merge 2 commits into
dhis2:masterfrom
daryn-brown:daryn-brown-capture-app-quality-fix

Conversation

@daryn-brown

Copy link
Copy Markdown

Summary

  • add strict types for organisation unit API responses, query results, cache entries, and subvalues
  • make useOrganisationUnit generic so callers receive the fields they requested
  • replace untyped query errors with FetchError
  • align getOrgUnitNames types with its existing { id, name } runtime response
  • add focused coverage for organisation unit name and ancestor caching

Why this is needed

The organisation unit name retrieval module is used across enrollment, event,
profile, tooltip, filtering, and relationship workflows. Its extensive use of
any allowed API response changes and invalid cache assumptions to bypass
TypeScript.

It also concealed a mismatch between the declared return type of
getOrgUnitNames and the value it actually returns. Strict response and cache
types now make these contracts explicit without changing the runtime data flow
or public behavior.

How to test

  1. Run:
    yarn test src/core_modules/capture-core/metadataRetrieval/orgUnitName/__tests__/orgUnitName.test.js --runInBand --watchAll=false
  2. Run:
    yarn tsc:check
  3. Verify organisation unit names and ancestor paths still render in enrollment
    and event views.

Checklist

  • Tests run locally
  • Type checks pass
  • No breaking changes were introduced

@daryn-brown
daryn-brown requested a review from a team as a code owner September 5, 2026 19:51
@sonarqubecloud

sonarqubecloud Bot commented Sep 5, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 New issue
1 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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