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

  • 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: temp_user.id"

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=**** \
           grafana/grafana-enterprise
2 Likes

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: temp_user.id” remote_addr=12.149.110.82 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=12.149.110.82 time_ms=56 duration=56.130928ms size=60 referer=https://www.abcd.com/org/users/invite 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.

2 Likes