Skip to content

fix: Block updates on expired events [DHIS2-21536]#24305

Merged
enricocolasante merged 1 commit into
masterfrom
DHIS2-21536
Jun 30, 2026
Merged

fix: Block updates on expired events [DHIS2-21536]#24305
enricocolasante merged 1 commit into
masterfrom
DHIS2-21536

Conversation

@enricocolasante

Copy link
Copy Markdown
Contributor

Summary

Fixes a gap in event date validation where completed events past their expiry window could
still be updated. The expiry check now anchors to the persisted completion date
when an event is already completed in the database, so updates are correctly blocked even when
the payload omits completedAt or status, and a fresh completedAt in the payload can no
longer reset the expiry clock.

Changes

  • DateValidator.java: Reworks validateCompletionExpiryDays to use the program's
    completeEventsExpiryDays as the early-return guard and to resolve the completion date the
    expiry check is anchored to via the new getCompletedDate / getPersistedCompletedDate
    helpers (which read the persisted event from TrackerPreheat). When the event is already
    completed in the DB, the persisted completion date wins over any value in the payload;
    otherwise, if the payload itself completes the event, its completedAt is used.
  • DateValidator.java: Threads TrackerPreheat into the validation so both TrackerEvent and
    SingleEvent types can look up their persisted counterparts.
  • DateValidatorTest.java: Adds coverage for the new behavior — expiry failures when the
    payload lacks completedAt/status, payload completedAt not resetting the clock on an
    already-completed event, passing within the expiry window, and the F_EDIT_EXPIRED
    authorization bypass; for both TrackerEvent and SingleEvent.

@sonarqubecloud

Copy link
Copy Markdown

@enricocolasante enricocolasante marked this pull request as ready for review June 29, 2026 12:43
@enricocolasante enricocolasante requested a review from a team as a code owner June 29, 2026 12:43
@enricocolasante enricocolasante merged commit be7fc8c into master Jun 30, 2026
23 checks passed
@enricocolasante enricocolasante deleted the DHIS2-21536 branch June 30, 2026 09:55
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