-
-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Bug Description
The signInWithCustomToken method in FirebaseAuth.kt throws an IllegalStateException: Task is not yet complete error when trying to authenticate users with custom tokens.
Error Details
Error Message:
ava.lang.IllegalStateException: Task is not yet complete
at com.google.android.gms.common.internal.Preconditions.checkState(com.google.android.gms:play-services-basement@@18.1.0:2)
at com.google.android.gms.tasks.zzw.zzf(com.google.android.gms:play-services-tasks@@18.0.2:1)
at com.google.android.gms.tasks.zzw.getResult(com.google.android.gms:play-services-tasks@@18.0.2:1)
at com.google.firebase.auth.FirebaseAuth.signInWithCustomToken(FirebaseAuth.kt:375)
To:
Impact
This bug prevents users from successfully authenticating with custom tokens in desktop/JVM environments, breaking the authentication flow for applications using this Firebase Java SDK.
Priority
High - This is a critical authentication bug that prevents core functionality from working.
Root Cause
The issue occurs because the method incorrectly tries to return source.result synchronously instead of returning the Task itself. This happens when:
- The method creates a Task with
enqueueAuthPost() - Adds a
continueWithoperation that callsupdateByGetAccountInfo() - Incorrectly returns
source.resultinstead of the Task
Code Location
File: src/main/java/com/google/firebase/auth/FirebaseAuth.kt
Method: signInWithCustomToken(customToken: String): Task<AuthResult>
Line: 375
Expected Behavior
The method should return a Task that can be properly awaited using .await() or handled with callbacks, allowing the asynchronous authentication process to complete before accessing the result.
Proposed Fix
Change the return statement from:
return source.result // ❌ Wrong - tries to get result synchronouslyTo:
return source.task.continueWithTask {
updateByGetAccountInfo()
} // ✅ Correct - returns Task for async handlingImpact
This bug prevents users from successfully authenticating with custom tokens in desktop/JVM environments, breaking the authentication flow for applications using this Firebase Java SDK.
Priority
High - This is a critical authentication bug that prevents core functionality from working.