Skip to content

fix: run GML import async and track it under the METADATA_IMPORT job [DHIS2-21758]#2250

Open
karolinelien wants to merge 3 commits into
masterfrom
DHIS2-21758-gml-import-job-progress
Open

fix: run GML import async and track it under the METADATA_IMPORT job [DHIS2-21758]#2250
karolinelien wants to merge 3 commits into
masterfrom
DHIS2-21758-gml-import-job-progress

Conversation

@karolinelien

@karolinelien karolinelien commented Jul 16, 2026

Copy link
Copy Markdown

Jira

DHIS2-21758Import/export app UI crash / hang when GML is imported

Symptom

Starting an org-unit-geometry GML import shows "Job started." and then hangs — no progress, no summary — even when the backend import actually succeeds.

Root cause (two issues on the GML path)

  1. The request was never made async. gml-helper.js passed isAsync: true to uploadFile but left async out of the request URL (params = \dryRun=${dryRun}`). So the backend ran the import **synchronously** and returned the report inline with no job id. uploadFile, told it was async, then stored the task with id: undefined, completed: falseand waited for a job that never existed — hence the perpetual "Job started" hang. (The metadata and geojson helpers correctly includeasync=${isAsync}` in the URL.)
  2. Wrong notifier category. Once made async, POST /api/metadata/gml runs as a METADATA_IMPORT job (there is a declared-but-unused GML_IMPORT job type). The app polled system/tasks/GML_IMPORT/<id> / taskSummaries/GML_IMPORT/<id>, which return nothing, so progress/summary would still never appear.

Fix

  • gml-helper.js: add async=${isAsync} to the request params so a real async job is created and its id is returned.
  • useTasks.js: map the GML task's poll category GML_IMPORT → METADATA_IMPORT (backend job type) for the event/summary queries only. GML_IMPORT stays as the UI category, so job grouping, the filter chips and "Recreate job" (/import/gml) are unchanged.

Verified against play/dev (2.44) and dev-2-43 (2.43)

With an org unit whose code matches the GML feature:

  • New async call POST /api/metadata/gml.json?dryRun=false&async=true200, returns a job id with jobType: METADATA_IMPORT.
  • Polling system/tasks/METADATA_IMPORT/<id> → streams progress → "Import complete with status OK … 1 updated", completed: true.
  • UI: import now completes with a summary instead of hanging (verified in a local build against play/dev).

Note: a 409/E5001 ("No matching object for reference") on this endpoint is expected and correct when no org unit matches the GML feature's uid/code/name — it is not part of this bug.

AI Assisted

karolinelien and others added 2 commits July 14, 2026 18:41
…IS2-21758]

The GML org unit geometry import (POST /api/metadata/gml) is executed by the
backend as a METADATA_IMPORT job, so its progress events and summary are
published under the METADATA_IMPORT notifier category. The app polled
system/tasks/GML_IMPORT/<uid> (and taskSummaries) instead, which always returns
an empty result, so the job appeared to start ("Job started.") but never
reported progress or completion and the view hung.

Map the UI import category to the backend notifier category when polling only,
keeping GML_IMPORT as the UI category used for grouping, filtering and job
recreation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The GML helper passed isAsync=true to uploadFile but omitted async from the
request URL, so the backend ran the import synchronously and returned the report
inline with no job id. The app then treated the synchronous response as an async
job (task left completed=false, no id), so the UI showed "Job started" and then
hung indefinitely -- even when the backend import had succeeded.

Add async to the request params (matching the metadata and geojson helpers) so a
real async job is created and its id is returned. Combined with the notifier
category fix in useTasks (the backend runs the GML job as METADATA_IMPORT), the
import now reports progress through to completion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dhis2-bot

Copy link
Copy Markdown
Contributor

🚀 Deployed on https://pr-2250--dhis2-import-export.netlify.app

@dhis2-bot
dhis2-bot temporarily deployed to netlify July 16, 2026 17:51 Inactive
@karolinelien
karolinelien marked this pull request as ready for review July 16, 2026 17:59
Move toNotifierCategory from useTasks into tasks.jsx next to the category
definitions it keys off, export it, and add a unit test asserting
GML_IMPORT maps to METADATA_IMPORT while every other category passes
through unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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