gosparkpost icon indicating copy to clipboard operation
gosparkpost copied to clipboard

Fix sending Transmission content with template_id.

Open Tang8330 opened this issue 2 years ago • 2 comments

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

Tang8330 avatar Oct 27 '23 01:10 Tang8330

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?

chrsmith avatar Jan 08 '24 15:01 chrsmith

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

Tang8330 avatar Jan 08 '24 16:01 Tang8330