After our Join.me call to debug this issue, I spent some time testing / debugging it.
There was nothing wrong in what you were doing.
After I figured it out and got it to work, and only then, I remembered that I went through this same issue 8 months back.
There is a 'GOTCHA' when it comes to velocity script testing.
'Send sample email' is not a good way for testing velocity scripts. Even if we choose a 'lead' to test the email with velocity script against, it does not 'accurately' evaluate the velocity script. In other words, when you 'send sample email' with Velocity script, all the 'lead token' values in the velocity script are NULL.
And that's why we keep on getting errors. And it all works perfectly fine when we hard code data to test.
To test, simply create a test smart campaign and execute it to send the test email to yourself.
It will work just fine.
I am sending you the script and the test email where it worked soon.
I guess the send Sample Email does not 'invoke' some Marketo server component to actually render 'lead's data in Velocity script.
I do not claim to have all the 'internal' knowledge of Marketo here but this is based on what I have experienced.
Hope this helps
I've noted this and will follow-up with our engineering team and see if we can change this behavior.
One thing I will add, is that it still gives me an error when I try to approve my email, so my workaround is to remove the content of my token, approve the email, then add the token content back, not ideal but it works.
Thanks for the help Rajesh!