Skip to content

[FIX] Bulk load accepts only one year/period at a time - #419

Merged
MiquelAdell merged 1 commit into
developmentfrom
fix/data-set-import-one-request-per-period
Oct 22, 2026
Merged

MiquelAdell merged 1 commit into
developmentfrom
fix/data-set-import-one-request-per-period

Conversation

@anagperal

Copy link
Copy Markdown

📌 References

📝 Implementation

When a data set has data input periods, DHIS2 only accepts the first period of each dataValueSets request. Values for the other periods are rejected with "Period: X is not open for this data set at this time", even when those periods are open. The org unit does not matter: several org units in the same period import fine.

Bulk Load sent up to 1000 data values per request, mixing periods, so a template with several years imported only the first one. The same happens with "Delete and import".

  • New chunkDataValuesByPeriod (src/data/Dhis2DataValueChunks.ts): groups the data values by period, in the order they appear, and then chunks each period by size.
  • InstanceDhisRepository.importAggregatedData uses it instead of _.chunk. The rest is unchanged: chunks are still posted one after another and merged into a single import summary, and data set completion still works per chunk.
  • Unit tests for the new function.

Tracker programs are not affected (tested with several org units, creating and updating), so they are not changed.

🔥 Notes for the reviewer

  • Temporary workaround. Once DHIS2-22277 is fixed, revert by putting back _.chunk(dataValues, bulkOperationChunkSize) in importAggregatedData and deleting Dhis2DataValueChunks.ts and its spec.
  • A template with N periods now sends at least N requests instead of one. Each request waits for its async job, so imports with many periods are a bit slower.

How to test

  1. Use a data set with data input periods open for several years (for example TUB - Annual data in dev, or Facility Assessment on play 2.41.10 after adding data input periods).
  2. Download its template and fill values for two org units in two open periods.
  3. Import it: all values are imported, with no "is not open" conflicts. On development, only the first period is imported.

📹 Screenshots/Screen capture

test-BL.webm

📑 Others

DHIS2 only accepts the first period of a dataValueSets request when the
data set has data input periods (DHIS2-22277), so imports and deletes
with several periods were partially rejected as "not open". Group the
data values by period before chunking them by size.
@anagperal
anagperal requested a review from MiquelAdell October 15, 2026 15:38
@bundlemon

bundlemon Bot commented Oct 15, 2026

Copy link
Copy Markdown

BundleMon

No change in files bundle size

Groups updated (1)
Status Path Size Limits
✅ Build Folder
./**/*
1.73MB (+1.98KB +0.11%) +20%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@MiquelAdell
MiquelAdell requested a review from xurxodev October 16, 2026 09:02

@xurxodev xurxodev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks @anagperal

Works fine!

@MiquelAdell some notes

  • The bug seems fixed upstream from 2.43. It reproduces on 2.41.10. the workaround can be removed once the instances are on 2.43 or later.

@MiquelAdell
MiquelAdell merged commit be349e1 into development Oct 22, 2026
11 of 12 checks passed
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.

3 participants