signInWithPassword does not return an error code when the login credentials are invalid
I confirm this is a bug with Supabase, not with my own application. I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
Most (all?) other supabase.auth methods return a code property in the error object, if there's any, as documented here.
supabase.auth.signInWithPassword does not, for some reason, and one has to check if the error message property is equal to "Invalid login credentials".
This breaks consistency across the platform and makes people write code that may not be future-proof. If error.message changes then it's gg, while error.code somehow implies a guarantee of stability across time.
To Reproduce
await supabase.auth.signInWithPassword({ email:[some valid email], password:[some invalid password] });
Expected behavior
An error object with a defined code property.
Screenshots
N/A
System information
@supabase/[email protected] @supabase/[email protected]
Node version: 20.15.0
Additional context
I < 3 supabase.
Same with "Email not confirmed".
I got the same issue
Thanks for opening!
This issue should not be occurring. Please can you update to the latest version of the SSR lib (0.4.0) and supabase-js?
Testing this currently with our auth example and the behaviour is as expected.
const { error } = await supabase.auth.signInWithPassword({
email,
password,
});
correctly throws an error on the server and the client receives a message in the URL.
Let us know how it goes!
The issue is not that an error is not thrown, that does happen, but the error object does not have a code property in (at least) these two cases, unlike all other auth errors.
Ah yes, thank you for the clarification! Transferring to the Auth repo as this seems to be a bug.
jfyi, this is identical to https://github.com/supabase/auth/issues/1631
Well then, let's close in favour of tracking it there!
Any update on this? This hard to debug as it occur to some random user
hello i have the same issue when using a wrong password or non existing email. do you have some update ?