Firestore fails with an Internal Error due to invalid Auth #3197
Comments
|
Thank you @jlaws for the incredibly detailed explanation and the debugging! Assigning to the Auth team who has more context about the decoding issue. |
|
It would be super helpful if you could point out where you saw Firestore suppressing this error. You shouldn’t have to work this hard to be able to report a problem. |
|
@jlaws Thanks for your detailed explanation. I've verified that this should be a bug on Auth side. I'm investigating and working on the fix. |
|
@renkelvin I use
which causes the setAuth to not be called. Note: You need to use a device to reproduce it. On a simulator it goes through a different code path. |
|
@jlaws Could you please help check if the fix works for you? You can apply the fix by adding |
|
Applied the fix from your PR manually and it works. Putting on my old obj-c readability reviewer @ Google hat: user.auth is set in both parts of the if, so it is safe to pull it out. That would turn the method in FIRAuth.m to this: |
|
Yeah, agree. |
|
I'm facing the same issue. I see the fix is already in |
|
@ValCanBuild 6.4.0 is stabilizing now and should be published next week. |
[READ] Step 1: Are you in the right place?
YES
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
After restarting the app from a cold start all future Firestore queries fail due to an Internal Error with no other information or details on what went wrong. I traced the call chain back to the FIRSecureTokenService where it is failing to retrieve fresh access tokens due to _requestConfiguration being nil. The error, before it is suppressed by all the call chains in Firestore, can be seen here:
The problem is that FIRSecureTokenService is created via initWithCoder and never has the API key set. In the encodeWithCode method it says this
I am not sure why the API key was only added to the encoding and not decoded, perhaps there was a plan to set it externally after this object was decoded in FIRUser (line 330) since FIRUser also has a _requestConfiguration. Regardless of why it was removed, I was able to fix the issue by parsing the stored APIKey and correctly creating the _requestConfiguration
Also, while debugging this issue I also noticed a bug on line 335 of FIRUser.m the correct parsing of APIKey should be
not
Steps to reproduce:
Ensure a user is logged in and their auth is stored via |encodeWithCoder:| on FIRUser.m. I used Google Authentication for this. Perform some Firestore queries, it should work fine after authenticating. Restart the app after the cached access token expires so that FIRSecureTokenService |requestAccessToken:| is called for an updated token during future Firestore queries. See the internal error.
The text was updated successfully, but these errors were encountered: