I'm not a modder, but I've been a programmer for over 20 years.
I believe that this issue is because the last thing in the cursor_stack was the upgrade planner, even though the blueprint is being edited. If that is the case, maybe you can check if the item in player.cursor_stack is a blueprint before calling is_blueprint_setup?
As an experiment I made the following change and it worked without crashing.
In lib/private/control-scripts/electric-offshore-pump.lua I change line 45-47 from
if player and player.valid and player.cursor_stack.valid_for_read and player.cursor_stack.is_blueprint_setup() then
local blueprint_entities = player.cursor_stack.get_blueprint_entities()
if blueprint_entities and next(blueprint_entities) then
to
if player and player.valid and player.cursor_stack.valid_for_read then
local blueprint_entities = player.cursor_stack.get_blueprint_entities()
if blueprint_entities and player.cursor_stack.is_blueprint_setup() and next(blueprint_entities) then
I do not know if the call to is_blueprint_setup is needed at that point, or if this will cause other bugs.