This is a result of lack of sorting in User::getGroups(). Encountered this myself in my dev wiki, not sure how to repro.
Related Gerrit Patches:
|mediawiki/core : master||Special:UserRights: Fix handling of empty conflict check value|
|mediawiki/core : master||user: Ensure returned user groups are sorted|
I'm getting this deterministically in Vagrant now; not sure if it's caused by the patch, not fixed by it or entirely unrelated. I'm guessing the last because as far as I can tell there isn't even any API request happening.