This causes it to pierce spell immunity, if the attack was started before, but lands after the target turns spell immune. Vice versa, if an attack starts while the target is spell immune, and hits after it's no longer spell immune, caustic finale debuff is not placed, despite the target no longer being spell immune.

Repro:
1. Pick Sand King and level up Caustic Finale
2. Create an enemy Enchantress, max out Untouchable and get Black King Bar
3. Order your Sand King to attack Enchantress
4. Before the attack lands, activate Black King Bar on Enchantress

Result: Despite being spell immune, Caustic Finale still places its debuff on Enchantress. This means the ability checks for spell immunity upon attack begin.

Expected: When spell immune, Caustic Finale should no place its debuff on the enemy. So it should check for spell immunity on attack hit, not start.