SparkPost / mandrill-sparkpost-templates

Translate Mandrill Handlebars templates into SparkPost templates
https://www.sparkpost.com/blog/mandrill-template-migration-tool-mst3k/
Other
6 stars 3 forks source link

Error while sending template to SparkPost: required field is missing #3

Closed mattiLeBlanc closed 8 years ago

mattiLeBlanc commented 8 years ago

Hi,

I cloned the migration tool locally and followed instructions. When running it and trying to migrate a template, I get 2 errors in 2 situations: 1) Using sandbox email it crashes on

TypeError: Cannot read property 'local' of null
    at Object.translateTemplate (/Users/[user]/www/npm/mandrill-sparkpost-templates/lib/index.js:86:56)

2) when NOT using sandbox email, I get this response in the 500 error

{"errors":[{"name":"SparkPostError","message":"Error while sending template to SparkPost: required field is missing"}]}

Running with node 5.3 and latest NPM (3.8.5 on OSX)

mattiLeBlanc commented 8 years ago

okay, I found the issue: the migration tool expects that in Mandrill all the fields are populated (from address, from email etc..). I didn't populate them because I took care of that in my controllers. So if you run into this message, make sure your mandrill templates have all the fields populated.

Maybe note for the developer of this package: if fields are not available, skip them? If someone has a lot of templates and is sending them programatically they might take care of the subject and send themselves in their controller. For migration, I now have to add values in the fields to be able to migrate.

ewandennis commented 8 years ago

Good feedback and thanks for the detailed analysis. This issue has been addressed in v0.1.1.