We’re trying to link users to their FB accounts but we get an error ‘ERROR: duplicate key value violates unique constraint “users_email_key” (SQLSTATE 23505)’. We tried to investigate the issue and found some code that could potentially cause it.
It’s quite possible this change introduced the issue on social linking:
The potential problem is on line 207 in core_link.go. Since we don’t have an email for our users, the result of the statement
email = COALESCE(NULLIF(u.email, ''), $4) will always be an empty string if $4 evaluates to an empty string. And our assumption is that it does since it is given as a string (never nil) in the param list. This results to a unique constraint violation when the second user tries to link to their FB ID (two players having ‘’ as email).
We can generate some random foobar email addresses for the players as a workaround but it would be nice to have a proper fix for this. Or is there something that we haven’t really figured out or are we just using it wrong?