Can mRNA vaccine have flaws and generate the wrong spike protein?
The mRNA won't be entirely perfect, but the imperfections will not matter.
The spike protein is big, encoded by thousands of base pairs in the virus. In the virus itself, it's not entirely homogeneous: there are always going to be small mutations that cause different variants to be produced, but nearly all of those are nearly identical.
The mRNA in a vaccine may also have some degree of copying errors introduced during amplification, which will produce some distribution of variants. Though the specifics are different, random copying errors in a synthetic process and random copying errors in natural viral replications will produce qualitatively similar types of distributions (more serious errors producing truncations and recombinations can occur in both as well, but similar arguments apply and they're even less likely to be functional).
Moreover, since only the spike protein is there, it can't actually produce a damaging infection, only teach your immune system what an infection looks like. Finally, since it's easy to validate a batch of mRNA via sequencing, ordinary quality control procedures should be fine to make sure what goes into the vial is what was planned (modulo the variances described above, when they are at a low enough frequency to fall below the threshold of discrimination).
In short: don't worry about the mRNA varying. If you're going to worry about something, worry about the virus varying enough that our nice, tightly controlled mRNA doesn't match it any more.