In my mod, each new capsule ammo recipe needs to be unlocked by the same technology that unlocks the corresponding base capsule. To do this, I look up the recipe that produces the base capsule, then check which technology unlocks that recipe, and attach the ammo recipe to it.
This worked fine in vanilla Factorio, because each capsule has exactly one recipe. However, this mod introduced an alternate recipe for the same capsule (refining recipe). Since my code wasn’t prepared for multiple recipes producing the same item, it mistakenly chose the alternate recipe instead of the real base recipe. That caused the new ammo to unlock with the wrong technology (the refining tech), instead of the intended one.
The fix was to make sure I only select the vanilla/base recipe for each capsule, and ignore any alternates.