Sanctuary + readied spell that affects an enethe

dnd-5ereadied-actionspells

If I am under Sanctuary and ready an action to cast a spell such as Shocking Grasp, what actually happens? Sanctuary says:

If the warded creature makes an attack, casts a spell that affects an enemy, or deals damage to another creature, this spell ends

Readying a spell says:

When you ready a spell, you cast it as normal but hold its energy, which you release with your reaction when the trigger occurs. To be readied, a spell must have a casting time of 1 action, and holding onto the spell's magic requires concentration. If your concentration is broken, the spell dissipates without taking effect. For example, if you are concentrating on the web spell and ready magic missile, your web spell ends, and if you take damage before you release magic missile with your reaction, your concentration might be broken.

So since I'm holding the energy of the Shocking Grasp, I believe the spell does not affect its target before its released. Would I be protected by Sanctuary until the readied action takes place? It seems that way to me, but then again the spell is cast and does affect an enemy…it just hasn't affected the enemy yet. I guess it comes down to parsing "a spell that affects an enemy"; does this mean "a spell that, at some point, affects an enemy" or "a spell that affects an enemy in this instance"?

Best Answer

You would be protected

For the second condition

casts a spell that affects an enemy

two things need to happen for your protection to lapse: (1) you cast a spell, (2) it affects an enemy. You could for example also cast Evard's Black Tentacles on an area, and the Sanctuary will not end until an enemy gets caught in the effect or someone takes damage from it.

The idea is that Sanctuary shields you as long as you take no directly aggressive actions, and that is technically expressed in the listed conditions. You can see this in the pedigree of the spell, which goes back all the way to first edition (even if it technically does not matter for fifth edition):

During the period of protection afforded by this spell, the cleric cannot take offensive action, but he or she may use non-attack spells or otherwise act in any way which does not violate the prohibition against offensive action.