unkeyed / unkey

Open source API management platform
https://go.unkey.com
Other
2.95k stars 303 forks source link

Handle database error when inserting a duplicate `hash` in the `keys` table #1665

Closed chronark closed 2 months ago

chronark commented 4 months ago

Preliminary Checks

Reproduction / Replay Link (Optional)

No response

Issue Summary

Right now we fail and dump the db error

Steps to Reproduce

insert the same hash twice

Expected behavior

It should regenerate the key and try again to avoid the colission

Other information

No response

Screenshots

No response

Version info

- OS:
- Node:
- npm:
linear[bot] commented 4 months ago

ENG-1082 Handle database error when inserting a duplicate `hash` in the `keys` table

DeepaPrasanna commented 4 months ago

In the case of migrating duplicate keys, I believe it should not regenerate the key.

chronark commented 4 months ago

Yes, this is for generating keys, not migrating

DeepaPrasanna commented 4 months ago

But in case of migrating, will it not be a good idea to show some error message rather than internal server error?

chronark commented 4 months ago

It would

DeepaPrasanna commented 4 months ago

It would

May I give it a try?

chronark commented 4 months ago

go for it

DeepaPrasanna commented 3 months ago

go for it

I was sure it gave an internal server error but I am not able to reproduce that anymore. Maybe I was wrong. It shows proper message when entered duplicate keys or hash. image