SparkPost / gosparkpost

SparkPost client library for the Go Programming Language
https://www.sparkpost.com/
Other
62 stars 40 forks source link

Fix sending Transmission content with template_id. #166

Open Tang8330 opened 1 year ago

Tang8330 commented 1 year ago

Current logic is flawed in 2 ways.

  1. Iterating over a Golang map is not deterministic
  2. Other data types are actually valid to pass into message such as CC and BCC which are map[string]string types. Logic would early return when it found template_id based on [1], but because iterating keys over a map is not deterministic, it would fetch CC and then err out because it's map[string]string not string
chrsmith commented 10 months ago

I came here to report the same problem and propose a similar fix. @Tang8330 were you able to find a workaround so you can reliably send your transmissions? Otherwise calls to transmission.ParseContent(...) will randomly fail. (Due to a map's keys always being returned in an "indeterminate" ordering.)

It seems like the only(?) workaround for using stored templates with Sparkpost is to simply not use this Golang library?

Tang8330 commented 10 months ago

@chrsmith I fixed the problem on my fork and we're using that in Production.