Scene broken! - Can't duplicate or delete objects in scene

Why is our scene broken? I briefly saw an error in the bottom bar that a child of an entity could not be found. None of us can delete objects in the scene anymore, and duplicating the scene also doesn’t work.

We used Violentmonkey to help us edit the scene; if needed for investigation I can post the script here.

There was an issue on older projects where it was possible to corrupt the scene. I’m not sure if these assets were from before that time or not.

If you are using Violentmonkey, it is possible to corrupt the scene if there is a mismatch between the parent and children data on what exists/doesn’t

There is a fix available that is mentioned in this thread: Cannot find child entity of parent "Root" - Editor error, can't delete entities

There are also more detailed steps in the later replies using the Editor API

The project isn’t that old so I doubt it’s that. Most likely the culprit is Violentmonkey, but what exactly would cause such a mismatch to occur? I do instantiate entities and delete them, but I only use the editor API. Are there certain dos and don’ts to consider? This would be important for us so we can avoid this issue in the future.

If you only used the Editor API, I can’t think offhand what would cause it.

The error comes up because the parent entity has a list of child GUIDs where one or more doesn’t exist in the hierarchy

If this is reproducible in script and separate project, we could take a closer look at it. Perhaps there is a bug in the Editor API

At this point, the fix mentioned in the thread I linked above should fix it

Unfortunately I don’t know how it can be reproduced. During all my tests, I never ran into the problem.
I will follow the fix above and write again if this occurs again.