auth icon indicating copy to clipboard operation
auth copied to clipboard

Adding error codes to ApiError

Open samirergaibi opened this issue 3 years ago • 36 comments

Feature request

Is your feature request related to a problem? Please describe.

I am building a website with supabase and the errors that is returned from supabase.auth only contains a general error code 400 and a message in english. This makes the different errors hard to distinguish from eachother.

Example: User tries to create an account but the user is already registered so the error returned from supabase.auth.signUp will be

{ 
  message: "User already registered",
  status: 400
}

Describe the solution you'd like

If the error included a specific error code mapped to particular error then providing a custom message would be easy.

Example:

{ 
  message: "User already registered",
  status: 400,
  errorCode: 1,
}

It would also be really awesome if the error codes was included in the documentation.

Describe alternatives you've considered

I've considered checking the string value returned in the error but if that would change in the future that would in turn break the application.

samirergaibi avatar Feb 06 '22 15:02 samirergaibi

+1 for this change, as at this time distinguishing between errors (and translating them to different languages), is completely contingent on parsing the message being returned (and if that message one day got changed, it would break whatever logic we've had to build on top of it)

joeyTedeschi avatar Feb 22 '22 04:02 joeyTedeschi

I realize that when a user signs up using an already in use email don't get any error messages, auth.signUp() just returns the user. i think in this case i wanna cath the error and tell the user that email is in use

a User already registered error message would be awesome

salazarr-js avatar Apr 12 '22 20:04 salazarr-js

I want to alert the user if they need to check their email for the invite link, so error code would be help on signIn here would really help

Andrewjeska avatar Sep 28 '22 15:09 Andrewjeska

I strongly support this request!
Error codes would facilitate the creation of dictionary data for translation and help with multilingualization.

I am developing an application for Japanese and currently there is no list of error messages, so I am having a hard time creating dictionary data.

aiji42 avatar Sep 29 '22 02:09 aiji42

+1 on this. How am I supposed to provide the user additional steps if their login attempt errors because their email hasn't been verified yet, but they can't find the verification code anymore?

florianwalther-private avatar Dec 25 '22 19:12 florianwalther-private

Related to supabase/supabase#12739

silentworks avatar Dec 25 '22 22:12 silentworks

Interested in this.

nickreese avatar Jan 13 '23 21:01 nickreese

Over a year later and this has not been addressed. I thought features like this were standard practice.

raheemja avatar Mar 02 '23 00:03 raheemja

no news on this? how people are handling authentication errors and internalization?

renansoares avatar Mar 12 '23 08:03 renansoares

Thought this was industry standard and not something to implement upon request. Any developments on this?

sharifbubuka avatar Mar 30 '23 10:03 sharifbubuka

This just made ditch supabase Auth for something else.

Its standard practise to return proper errors.

But till now over a year nothing has been done. There is no proper CURL documentation for us to implement the rest Auth into a SDK ourselves.

Even on the little examples, errors are not treated well. this is a no no for me,shows an unserious company in this aspect

otyang avatar Apr 02 '23 11:04 otyang

Adding stable error keys to the returned JSON would be great (e.g., user.already.registered). That's clearer than abstract error codes ala Oracle.

And the ideal would be using the structure proposed by RFC 7807:

  • https://github.com/NationalBankBelgium/REST-API-Design-Guide/wiki/Error-handling-Error-details
  • https://github.com/NationalBankBelgium/REST-API-Design-Guide/wiki/Error-handling-Example-with-a-single-error
  • https://github.com/NationalBankBelgium/REST-API-Design-Guide/wiki/Error-handling-Example-with-multiple-errors
  • https://github.com/NationalBankBelgium/REST-API-Design-Guide/wiki/Error-handling-Example-with-parameters
  • https://github.com/NationalBankBelgium/REST-API-Design-Guide/wiki/Error-handling-Example-with-additional-metadata

dsebastien avatar Apr 12 '23 09:04 dsebastien

+1 on this

AdamEisfeld avatar Apr 18 '23 17:04 AdamEisfeld

I ran into the same issue and started collecting possible error messages by going through the GoTrue implementation.

I collect the errors for each endpoint in this Google Sheets doc. It's WIP so everything in this sheet is a little bit messy at the moment.

I also created a npm package that offers an error handler method for each function of GoTrue JS and therefore also Supabase JS.

joeldomke avatar Jul 02 '23 13:07 joeldomke

Thx a lot Joel !

Le dim. 2 juil. 2023 à 15:24, Joel Domke @.***> a écrit :

I ran into the same issue and started collecting possible error messages by going through the GoTrue implementation.

I collect the errors for each endpoint in this Google Sheets doc https://docs.google.com/spreadsheets/d/1GRFrER_WrleH7XgrzM_wHnZNNTtdH1Bc0cGa5kvyOQM/edit?usp=sharing. It's WIP so everything in this sheet is a little bit messy at the moment.

I also created a npm package https://github.com/joeldomke/supabase-errors-jsthat offers an error handler method for each function of GoTrue JS and therefore also Supabase JS.

— Reply to this email directly, view it on GitHub https://github.com/supabase/gotrue/issues/915#issuecomment-1616660491, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABA5QT2GYVJ7FZHAZPVVMDXOFY7XANCNFSM6AAAAAAUGLI6EA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

caipicoder avatar Jul 03 '23 07:07 caipicoder

Running into the same issue – would love to have standardized error codes for auth (I'm using supabase.auth.signInWithOtp() specifically). Firebase has a doc about this: https://firebase.google.com/docs/reference/js/v8/firebase.auth.Error

drummerjolev avatar Aug 08 '23 08:08 drummerjolev

+1 on this

CharleeWa avatar Aug 22 '23 03:08 CharleeWa

Such improvement would be great for developer experience, +1 to this idea.

mwoss avatar Sep 11 '23 12:09 mwoss

Any progress on this would be great help! Is there a way we can contribute ourselves?

elglogins avatar Sep 15 '23 07:09 elglogins

+1, Firebase has these standard error codes and it really is essential if you want to, for example, translate the messages

bielcarpi avatar Dec 08 '23 20:12 bielcarpi

+1, it's hard to use registration/signin manually with react native development using supabase lib, i am a js/ts library user but i would recommend having code status too...

I have already created feature request since Sept but no one have ever response to it

mashwishi avatar Dec 14 '23 04:12 mashwishi

+1 on this, an error code it would be great to distinguish between errors and then we can make our own internationalization, but using a switch inside an effect its no option for a first class product, if we want to scale to millions we need that feature. By the way all the good vibes to the supabase team, you're making a incredible work, with my team recently started a new project integrating it with next.js 14 and we are amazed.

Ianduha13 avatar Jan 16 '24 23:01 Ianduha13

Over a year later and this has not been addressed. I thought features like this were standard practice.

They have been busy with the unusable AI bs.

Soren-365 avatar Feb 05 '24 11:02 Soren-365

+1. Why is this not a standard already?

dannyraede avatar Feb 16 '24 18:02 dannyraede

It's been two years and still no update?

qaynam avatar Feb 17 '24 08:02 qaynam

It's been two years and still no update?

mashwishi avatar Feb 18 '24 04:02 mashwishi

This is an essential feature. +1 to this

SamiChab avatar Mar 13 '24 12:03 SamiChab

Really, the lack of support for this is disappointing.

Being able to process errors in order to show users a customized (or localized) message is an essential feature.

262hz avatar Mar 13 '24 14:03 262hz

@SamiChab @262hz Looks like the PR for this has been merged just recently:

https://github.com/supabase/gotrue/pull/1377

I believe it's in a release candidate at the moment.

haydn avatar Mar 14 '24 02:03 haydn

It was already merged but i think its's for auth-js only is it different from supabase-js using supabase.auth?

is this only for auth-js ? and supabase-js not included?

            const response = await supabase.auth.signInWithPassword({
                email: email,
                password: password,
            })

image Version: "@supabase/supabase-js": "^2.41.1"

mashwishi avatar Mar 30 '24 05:03 mashwishi