Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errorCode is undefined because data.error is not processed #928

Closed
tvogel opened this issue Jun 19, 2024 · 4 comments
Closed

errorCode is undefined because data.error is not processed #928

tvogel opened this issue Jun 19, 2024 · 4 comments

Comments

@tvogel
Copy link

tvogel commented Jun 19, 2024

This is with my local supabase start environment (which might have an effect on the GoTrue version?):

When I get an authentication failure from auth-js, e.g. because of an invalid password, I do not get the useful invalid_grant error code but instead, it is undefined (from console.dir(error)):

AuthApiError: Invalid login credentials
​__isAuthError: true
​code: undefined
​columnNumber: 5
​fileName: "http://localhost/node_modules/.vite/deps/@supabase_supabase-js.js?v=71e4d0b2"
​lineNumber: 3828
​message: "Invalid login credentials"
​name: "AuthApiError"
​stack: <removed>
status: 400

This seems to be because, in

and below, it is checking only fordata.code and data.error_code. It seems to me that data.error should be checked as well, because that is what I see in the JSON reply in the network packet:

{"error":"invalid_grant","error_description":"Invalid login credentials"}

Because I am not aware what protocol version checks might be necessary, I won't try to file a pull request. (Also, I was not successful setting up a local version of auth-js.)

@tvogel
Copy link
Author

tvogel commented Jun 19, 2024

Ah, by the way, a similar issue appears with verifyOtp() even though, here, the JSON in fact looks like:

{"code":"otp_expired","message":"Token has expired or is invalid"}

but still, the code does not make it into the error object:

AuthApiError: Token has expired or is invalid
​__isAuthError: true
​code: undefined
​columnNumber: 5
​fileName: "http://localhost/node_modules/.vite/deps/@supabase_supabase-js.js?v=71e4d0b2"
​lineNumber: 3828
​message: "Token has expired or is invalid"
​name: "AuthApiError"
​stack: <removed>
status: 403

@tvogel
Copy link
Author

tvogel commented Jun 19, 2024

Could it be that the API version check fails because GoTrue is not exposing the version header to the script, see:

https://github.com/supabase/auth/blob/06464c013571253d1f18f7ae5e840826c4bd84a7/internal/api/api.go#L331

@silentworks
Copy link
Contributor

The Supabase auth team is aware of this issue and is tracking it on the Supabase Auth GitHub repo supabase/auth#1631

@J0
Copy link
Contributor

J0 commented Aug 27, 2024

Hey,

Thanks for flagging the issue. A fix has supabase/auth#1721 and this should be patched later this week or early next week with our next deploy

Hope this helps. I'm going to close for now but feel free to re-open or head to #804 if there are any issues after upgrading. You can track the version under Settings > Infrastructure > Service Versions > Auth version. Should be good to go once your project version is v2.159.0 or later

@J0 J0 closed this as completed Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants