VibeDict

🗄️Tried to save a value that already exists (duplicate)

What you'll see
duplicate key value violates unique constraint "users_email_key"

A value that should exist only once (like an email) is already saved, and the same value was saved again.

🤔 Why does it happen?

  • Someone tried to sign up twice with the same email
  • The button was pressed twice, so the same request went out twice

🔧 Try this

  1. Check whether it already exists before saving, or change it to update if it exists (upsert)
  2. Disable the button for a moment after it's pressed

🤖 Ask your AI like this

I get 'duplicate key value violates unique constraint' when saving. Please fix it so that when the value already exists, it tells the user or overwrites it (upsert), and make sure it only saves once even if the button is pressed twice. [Paste the full error here]

Replace the [ ] parts with your own situation, and paste the error with a few extra lines before and after it.

Related terms

Other errors in this group