https://mods.factorio.com/mod/DeadlockLargerLamp
Causes a load time error about collision masks not matching.
I'm guessing it's because you're doing a search for all type = "lamp" entities, but the copper lamp from that mod is type = "assembling-machine".
I can't think of a way to catch this dynamically (unless there's a built in API/function for a reverse lookup of which entities have the property next_upgrade set to the entity you're working on), so may be good to just do it manually for the copper lamp if that mod is installed.
Edit: Oh, wait, now that I'm digging in your code, I see you already have a something in there for the copper lamp. Hmm... let me investigate further....
Edit2: Yup, whoops, sorry. Looks like it's actually the Hovercraft mod doing it, but Factorio wasn't giving me a complete list of possible mod culprits. Sorry about that!