Menu

1 / 2

Your GraphQL API has two error modes: leaking Postgres internals, or "Internal server error"

DEV Community: typescript·Muhammad Adnan·17 days ago
#HklDOD4r
#devtotypescript#devto#dev#email#code
Reading 0:00
15s threshold

Try this on your GraphQL API: sign up twice with the same email.

On a lot of TypeScript + Postgres backends you get one of two responses.

Mode 1: the leak.

{ "errors" : [{ "message" : "duplicate key value violates unique constraint \" users_email_key \" " , "extensions" : { "code" : "INTERNAL_SERVER_ERROR" } }], "data" : null }

Enter fullscreen mode

Exit fullscreen mode

Your table name, your constraint name, and a hint about your schema, sent to anyone who asks. And the client still can't act on it, because the code says "internal server error" for what is really "that email is taken".

Mode 2: the mask. Someone noticed Mode 1 and added a formatError that replaces every message with "Internal server error" . Now nothing leaks, but the signup form shows "Something went wrong" for a duplicate email, an invalid input, a missing record and an actual outage alike.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.