Failed to save invite to database" error="UNIQUE constraint failed:"

  • What Grafana version and what operating system are you using?
    v9.4.3 (cf0a135595) Docker

  • What are you trying to achieve?
    Add a new invite

  • What happened?

I added an invite, which worked, but failed on the SMTP.
I stopped docker, and restarted with the corrected SMTP config.

Now I get
Failed to save invite to database" error="UNIQUE constraint failed:"

docker run -d --restart=always --net=host --name=grafana \
           -v grafana-storage:/var/lib/grafana \
           -e GF_SMTP_ENABLED=true \
           -e GF_SMTP_HOST=**** \
           -e GF_SMTP_USER=**** \
           -e GF_SMTP_PASSWORD=**** \
           -e GF_SMTP_FROM_ADDRESS=**** \

Same with me also, I tried to re-invite with correct SMTP settings and it fails with following logs:

logger=context userId=1 orgId=1 uname=admin t=2023-03-12T05:51:01.711870376Z level=error msg=“Failed to save invite to database” error=“UNIQUE constraint failed:” remote_addr= traceID=
logger=context userId=1 orgId=1 uname=admin t=2023-03-12T05:51:01.712023808Z level=error msg=“Request Completed” method=POST path=/api/org/invites status=500 remote_addr= time_ms=56 duration=56.130928ms size=60 referer= handler=/api/org/invites
logger=cleanup t=2023-03-12T05:57:20.555465786Z level=info msg=“Completed cleanup jobs” duration=68.154543ms

1 Like

For now, you can delete the temp_user’s

sqlite3 grafana.db "delete from temp_user;"

Met same problem here, can be easily re-produced

After starting a new Grafana instance with no extra parameters,

  1. Invite user a, this will prompt SMTP error message, but the invitation still works
  2. Invite user b, this will fail and return 500
1 Like

After this, I am only able to send one invite. It again fails for second invite.

1 Like

Same here, only 1 invite can be sent.

I have to “delete from temp_user” after each successful user registration.

grafana 9.4.3, SMTP OK.

I just created an issue here, this seems related to latest version of Grafana.