What happens if a paper with same topic gets published while writing undergraduate thesis? What happens when a topic for a Bachelor's thesis is submitted and while the student writes their thesis, a paper discussing the exact same topic is published by researchers of a different university?

This is merely a scenario. I'm not in this situation. But I feel like it concerns me a lot as I would be, had I written my theses 3 years earlier, as I received an email today informing me that the topic I proposed to a chair would be a good topic but has already been looked into by 5 researchers at a French university and the French Institute for Research in Computer Science and Automation somewhat short of 3 years ago. The topic of their paper exactly matches what I planned to write about, so I think this happening is plausible. However, I can't seem to find information online about how it would be handled.

In such a scenario, is the student allowed to finish their thesis? How would the publication of the paper impact the requirements concerning the thesis?

Had this happened to me (with the topic I proposed), I would've suddenly have access to everything I wanted to find.

Should the field or location matter: I'm a computer science student in Germany.
As far as I know, in Germany, Bachelor's theses do not necessarily have to be "research", so novelty is not mandatory to graduate. Reproducing existing research would be fine, as long as it is noted and no plagiarism occurs (and the effort is commensurate: there will probably be implementation decisions to be made, etc.).

I have seen several bachelor theses on subjects such as "implementing PCIe communication" "writing a linux device driver" "build a softcore processor for the open-license parts of the ARMv4 instruction set" which have no novelty or research value but significant engineering effort. If the B.Sc. student has no ambitions for an academic career, this type of thing is perfectly appropriate and in line with their future professional work.