this has happened on both ends...
guy with no knights activated when the barbs arrive. not enough knights to stave off the barbs, so least knights player(s) lose a city.
the bug is that it immediately re-upgrades the settlement into a city, so that no city is actually lost.
i've seen it happen with other players - and today it happened when my last knight was stolen and the barbs landed. i choose the city i want to lose, and it immediately re-upgrades the settlement into a city with no expenditure of resources.
i had 5 settlements and 2 cities at the time, so it created the 'must upgrade first' icon for the settlement and before i am able to finish the rest of my turn, the settlement is auto upgraded.