I don't think current legal frameworks are equipped to handle these types of generative works. There will need to be either new laws, or at least some legal precedence established. For example, it would make total sense for stuff posted publicly to optionally have a "not to be used to train models" license. But models are being trained on public data that pre-dates anyone thinking that is something that they should worry about.
For a prominent example, WINE goes to extreme ends to ensure their code isn't derived from any prior direct knowledge of Microsoft code. Replicating functions of released binaries with original code is fair game, but reverse engineering or copying Microsoft code is a hard no-go.
As far as AI is concerned in all this, it's probably even easier to distinguish the unacceptable. Whereas humans can argue for plausible deniability, we clearly know what data an AI is fed to generate subsequent output. So unless an AI is certified to never have eaten licensed materials, literally everything it produces will be license infringements.
The training data doesn’t exist at runtime, and if the developers are competent then it only learned a bit or two from each input snippet. So, though even though it’s certainly a highly capable compression algorithm, verbatim copies shouldn’t be… possible.
My best guess for this bug is that a lot of already plagiarised the code. AI has a habit of holding up a mirror to humanity. Sometimes we don’t like what we see.