Skip to content

Conversation

@enricocolasante
Copy link
Contributor

@enricocolasante enricocolasante commented Jan 20, 2026

The validation for nextScheduleDate in ProgramStageObjectBundleHook was relying on the fact that the nextScheduleDate data element was present in the the programStage.getDataElements() set and it was using contains() method to check it.
contains() method uses equals() method that for DataElement is implemented in the chain of BaseDimensionalItemObject and all the objects that extend it and it uses some fields to check equality that are coming directly from the payload, so it depends on the shape of the payload if the contains() method would success or fail.

Almost by coincidence, the payload coming from Maintenance App when saving a whole program stage was passing the validation, but in the new Maintenance App we are using PATCH and only updating one field at a time and the contains() approach is not working.
I changed the check to only look at the UID of the data element that it is in fact the only required field when patching.

@sonarqubecloud
Copy link

@enricocolasante enricocolasante requested review from a team and david-mackessy January 21, 2026 13:24
@enricocolasante enricocolasante marked this pull request as ready for review January 21, 2026 13:24
.formatted(dataElement.getUid()))
.content(HttpStatus.OK)
.as(JsonWebMessage.class);
assertEquals("OK", message.getStatus());
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be just me, but I would also assert that the patch value is now in place to be 100% sure it works (GET ProgramStage and check nextScheduleDate)

@larshelge larshelge merged commit 740d356 into master Jan 26, 2026
16 checks passed
@larshelge larshelge deleted the DHIS2-20042 branch January 26, 2026 09:18
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.

4 participants