supabase-community / supabase-kt

A Kotlin Multiplatform Client for Supabase.
https://supabase.com/docs/reference/kotlin/introduction
MIT License
377 stars 37 forks source link

[Bug]: Could not serialize Email register response #59

Closed lucat1 closed 1 year ago

lucat1 commented 1 year ago

General Info

What happened? (include your code)

I am running a self hosted SupaBase server with email "autoconfirm", so when a user registers he is automatically verified. Therefore I believe the goTrue server does not provide the confirmation_sent_at field in the JSON response. Could this field be made optional as a simple fix?

Platform(s)

Android

Relevant log output

W/System.err: kotlinx.serialization.MissingFieldException: Fields [id, email, confirmation_sent_at, created_at, updated_at] are required for type with serial name 'io.github.jan.supabase.gotrue.providers.builtin.Email.Result', but they were missing
jan-tennert commented 1 year ago

Yea could be, but the error says all fields are missing. Can you somehow see the payload you received? The next update shows it directly in the error message

jan-tennert commented 1 year ago

Published 0.8.1-dev, which should print out the actual payload (should be available in a few minutes)

lucat1 commented 1 year ago

I'll try it out. I tried earlier and was not able to intercept the HTTP traffic with a proxy unfortunately

lucat1 commented 1 year ago

With this version I get the following compilation error:

Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
jan-tennert commented 1 year ago

Try 0.8.1-dev-2

lucat1 commented 1 year ago

Here's the output. I believe I guessed it right in the first place:

W/System.err: io.github.jan.supabase.exceptions.SupabaseEncodingException: Couldn't decode sign up email result. Input: {"access_token":"redacted","token_type":"bearer","expires_in":3600,"refresh_token":"redacted","user":{"id":"bab8aa39-4f5a-441a-bb1d-95e4a11e8f79","aud":"authenticated","role":"authenticated","email":"a@test.com","email_confirmed_at":"2023-02-24T12:56:48.514995823Z","phone":"","last_sign_in_at":"2023-02-24T12:56:48.536930217Z","app_metadata":{"provider":"email","providers":["email"]},"user_metadata":{},"identities":[{"id":"bab8aa39-4f5a-441a-bb1d-95e4a11e8f79","user_id":"bab8aa39-4f5a-441a-bb1d-95e4a11e8f79","identity_data":{"email":"a@testests.com","sub":"bab8aa39-4f5a-441a-bb1d-95e4a11e8f79"},"provider":"email","last_sign_in_at":"2023-02-24T12:56:48.51182194Z","created_at":"2023-02-24T12:56:48.511865Z","updated_at":"2023-02-24T12:56:48.511865Z"}],"created_at":"2023-02-24T12:56:48.507148Z","updated_at":"2023-02-24T12:56:48.541193Z"}}
jan-tennert commented 1 year ago

Weird that kotlin says all fields are missing 🤔 . Well I'll push out 0.8.1 with the fix in a few minutes

jan-tennert commented 1 year ago

Nvm, just realized this is not the result the sign-up function expects. It's the session

jan-tennert commented 1 year ago

Should be fixed in 0.8.1-dev-3, the sign up function now returns null if autoconfirm is enabled (and automatically logs in) Means sign up now has the same effect as loginWith when autoconfirm is enabled

lucat1 commented 1 year ago

Cool! I'll try it out now

jan-tennert commented 1 year ago

Cool! I'll try it out now

Does it work? Would release 0.8.1 if it's fixed

lucat1 commented 1 year ago

Sorry, I forgot to reply. Yes it does indeed work!

jan-tennert commented 1 year ago

Alright, then I'll close this issue. If you need further help, feel free to reopen this issue or create another one!