Hi,
I am maintaining the Miniloader Redux (https://mods.factorio.com/mod/miniloader-redux) mod and I am chasing this bug report with Blueprint Sandboxes: https://github.com/hgschmie/factorio-miniloader-redux/issues/35
I tracked that down to Blueprint sandboxes only firing "script_built" when upgrading. In the normal game, when using the upgrade planner, the game fires "on_robot_mined_entity" on the old entity and then "on_robot_built_entity" to create the upgraded version.
The same when doing a fast replace: First "on_player_mined_entity" is fired for the old entity, then "on_built_entity" for the new entity.
With the Blueprint sandboxes not firing a delete event, the internal state of the miniloader (which consists of multiple, hidden entities) gets confused and as a result, the upgrade fails.
This seems to be tied to the blueprint sandbox intercepting various events (mainly God.Upgrade) and trying to upgrade by doing a fast replace. Unfortunately, create_entity with fast replace does not raise a delete event.