In the Sync module, sync records are replayed on a remote server by saving each item in the record by Hibernate one by one.
In the case of Obs Groups, each Obs is represented by sync item that needs to be saved, and then the Set association that ensures the right obs are in the right obs group is saved. Unfortunately, this logic now breaks in the latest OpenMRS versions.
The resulting error is thrown from the ImmutableObsInterceptor, which is failing due to the fact that when flushing, it thinks the state of the Obs groupMembers has changed (from empty to containing Obs). I'm not entirely sure why this is happening now and it wasn't happening before, but may be due to changes in the Hibernate version.
I have not yet identified a straightforward fix in the sync module, but I have been able to fix things by bypassing the validation checks built into the ImmutableObsInterceptor. This ticket is to provide a supported mechanism in our ImmutableEntityInterceptors that enable bypassing validation for particular operations as needed by the invoking code.