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?
Hi @ari-skunkworksgames, you’re right this looks like a change in behaviour introduced with that feature. We’ve made improvements which fully address this issue, they’ll be part of the next release - keep an eye on the releases page.
That said this is a little unusual since the expectation is social accounts always include an email address, and as far as I’m aware Facebook does not allow registration without an email address. This may be an access token permission/scope issue since Nakama attempts to retrieve id,name,email,picture - does the token you supply to Nakama have adequate access to these fields?
Thank you for you quick response @zyro. Afaik, users can limit the access to their email address and prevent us from getting it despite our efforts - but again, I could be wrong. Also, we would like to limit the amount of PII data we copy to our DB and since we don’t really need email for anything, we would rather not copy it.
We will be monitoring the releases for this, thanks.