After learning to mod, I found the problem IS with your mod: you assume an thing.icon exists. This is ironic because YOUR items and entities do not have an icon.
To fix it:
First:
local base_icon_path
local base_icons_path
local icon_t
Then above the tier1 to tiermax and tech_icon_path:
base_icon_path = data.raw.item[machine_name].icon
base_icons_path = data.raw.item[machine_name].icons
Above the data:extend in the loop:
icon_t = {}
if base_icon_path then
icon_t[1] = { icon = base_icon_path }
icon_t[2] = { icon = overtier_icon_prefix..tier..overtier_icon_suffix, tint = overtier_icon_tint }
else
icon_t[1] = { icon = base_icons_path[1].icon }
icon_t[2] = { icon = overtier_icon_prefix..tier..overtier_icon_suffix, tint = overtier_icon_tint }
end
And then in the item and entity:
icons = icon_t,
I did those in steam-engines and steam-turbines. It might be worth generalizing it, and doing it for each group, since technically one of icon+icon_size, icons[1-n].icon + icon_size, or icons[1-n].icon + icons[1-n].icon_size are required.
Link to files with changes:
https://drive.google.com/open?id=1U8Vf1DJlYQXaLh9CHGZJE9gwoX4xsMhZ