Theoretical question about visas and citizens

It might be a bit of a silly question, but I thought about it a few days ago and wonder what will happen: say someone is a German citizen, but they don't know it. They then come to Germany and get any kind of longer-term visa, thinking they're a non-EU citizen. The Ausländerbehörde has no reason to think otherwise, too. Then a few years down the line they go to srart the Einbürgerung process and discover that they are in fact a citizen already. Technically, it was illegal to give them a visa. w What happens next? Can they ask for all of their payments to the AB be returned? Could they demand some repapration for being unallowed to work more in the years they were considered as "Ausländer" (if for example they had a student visa)? Are there other possible consequences?

I assume there won't really be any consequences, but I just wonder. It probably happened at least a few times in the past.