unkey icon indicating copy to clipboard operation
unkey copied to clipboard

Adjust DB operation error codes for better classification

Open Flo4604 opened this issue 2 months ago • 1 comments

@imeyer said:

all of this looks good!

one thing i think we may want to do is not return 5xx for DB operation issues.. the 4xx class maps reasonably well..

in this case we would return a 409 because it's conflict on an entity.. and if you think about the model of the app server talking to the database, the server is the client, thus when talking SQL to it it'd be like this:

400 -> malformed query 422 -> CHECK() failures (unique constraints, other custom constraints) 404 -> entity doesn't exist

it would be useful to make connection issues into 5xx class

500 or 503 for db connection issues (not including timeouts) 504 for timeouts

this way, we will still alert on valuable db issues.. but we can have softer alerts on rates of 4xx classes (labels then drive more urgency depending on the value)

Flo4604 avatar Oct 17 '25 08:10 Flo4604

ENG-2121

linear[bot] avatar Oct 17 '25 08:10 linear[bot]