GitLiveApp / firebase-java-sdk

A pure java port of the Firebase Android SDK
Apache License 2.0
16 stars 5 forks source link

signInWithEmailAndPassword() coroutine hangs on error #7

Closed fmasa closed 2 months ago

fmasa commented 3 months ago

When the email is invalid, the password is invalid, or the email is not found, the API returns 400 with an error payload. From that the error.message JSON field should be passed as errorCode to the FirebaseException constructor.

Right now HTTP message (which is an empty string) is passed instead and since the FirebaseException requires the error code to be not empty, the constructor throws an exception. This exception is not passed to Task and the coroutine is never resumed.

https://github.com/GitLiveApp/firebase-java-sdk/blob/c68b16cd0c9428395ddf580a7c2b6a09696321e4/src/main/java/com/google/firebase/auth/FirebaseAuth.kt#L249

Exception in thread "OkHttp Dispatcher" java.lang.IllegalArgumentException: Given String is empty or null
    at com.google.android.gms.common.internal.Preconditions.checkNotEmpty(com.google.android.gms:play-services-basement@@18.1.0:2)
    at com.google.firebase.auth.FirebaseAuthException.<init>(com.google.firebase:firebase-auth-interop@@20.0.0:2)
    at com.google.firebase.auth.FirebaseAuthInvalidUserException.<init>(FirebaseAuthInvalidUserException.kt:3)
    at com.google.firebase.auth.FirebaseAuth$signInWithEmailAndPassword$1.onResponse(FirebaseAuth.kt:248)
    at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
nbransby commented 3 months ago

Will look at this when we can, a PR would def speed up the process thanks!

fmasa commented 2 months ago

@nbransby I wanted to do that, but I couldn't get the library to build.

nbransby commented 2 months ago

You followed the instructions? https://github.com/GitLiveApp/firebase-java-sdk?tab=readme-ov-file#building-and-contributing

fmasa commented 2 months ago

@nbransby I sort of got this to work, but there were some problems (I opened #10 for that).

I created the PR #9

taetae98coding commented 2 months ago

same issue