We're experiencing an insane bug where seemingly random bytes are some 90% of the time being tacked on to an email field right at the point when the email is being saved. Here's an example of what might occur:
From params: '[email protected]' Before validate: '[email protected]' After validate: '[email protected]' Before save: '[email protected]' Value in object after save: '[email protected]' Retrieve record just created by id, and fetch id: '[email protected]\u007f'
Where the heck did that \u007f
(the UTF-8 delete character!!!) come from?! That's by far the most common garbage that shows up. Here's a list some other valid byte sequences that have appeared from time to time:
r\u007f U\u007f a\u007f #m$\u007f
Sometimes I get totally garbage bits, I can't tell if there are more bytes than these due to a PG::CharacterNotInRepertoire
error:
0xde 0x4d
0xf6 0x7f
0xbc
0xe3 0x6c 0x24
Given the PG::CharacterNotInRepertoire
errors that occur, I'm assuming this is happening somewhere immediately before the value is being saved, but outside of the scope of my application code.
Note that this is strangely not happening for any other fields for the user.
Here are all the callbacks that currently touch the email address:
#strip!
and#downcase!
before validation- Format validation with the regex
\A[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,20}\z
Some app info:
- Ruby v2.2.0
- Rails v4.1.8
- Postgres v9.3.2
- PG v0.17.1