The bug
In the player's NBT data, the previousPlayerGameType tag is used to store a gamemode ID. However, its name refers to the gamemode as the "game type", which is inconsistent with other mentions of gamemodes.
To reproduce
/data get entity @s previousPlayerGameType