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

[App Check] Return error if refreshed token is nil #11625

Closed
wants to merge 4 commits into from

Conversation

andrewheard
Copy link
Contributor

@andrewheard andrewheard commented Jul 27, 2023

Added a nil check in FIRAppCheck's refreshToken method.

This handles an edge-case (still under investigation) where FIRAppCheckProvider getTokenWithCompletion:'s handler is called with nil for both the token and error, which results in a crash in postTokenUpdateNotificationWithToken: (attempting to populate an NSDictionary value with nil).

[self.tokenRefresher updateWithRefreshResult:refreshResult];
[self postTokenUpdateNotificationWithToken:token];
return token;
if (token) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I've been doing Swift too long, but why are lines 321 and 324 Nullable?

Should null be detected earlier and pass along nonnulls?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right, but I suspect that there may have been a case where line 321 was justified. In that case, setting a nil token in storage would wipe storage– which may be desireable.

I don't however think that line 324 should use a non-nil token.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that line 324 should be non-nil. [self.storage setToken:token] on line 322 resolves the promise with nil unless there's an error removing the token from storage here.

@andrewheard andrewheard marked this pull request as ready for review July 28, 2023 15:26
Copy link
Member

@ncooke3 ncooke3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after discussion later today

@paulb777
Copy link
Member

Please close, merge, or comment. We plan to close stale PRs on November 28, 2023.

@andrewheard andrewheard deleted the ah/appcheck-refreshtoken branch November 14, 2023 16:00
@bryansum
Copy link

This is still an active crasher for us as of 10.13.0. Is there a reason why this was closed vs. merged in?

@andrewheard
Copy link
Contributor Author

This is still an active crasher for us as of 10.13.0. Is there a reason why this was closed vs. merged in?

@bryansum Would you mind filing a new bug with any debugging info you can provide?

My main hesitation with merging this is that it doesn't fix the underlying problem, just hides it, since the providers should never return (nil, nil).

@paulb777
Copy link
Member

@bryansum Do you still see the crash with 10.17.0 or newer?

@bryansum
Copy link

I'll upgrade soon and let you know. Thanks for the response.

@bryansum
Copy link

bryansum commented Dec 10, 2023

Updated to 10.17.0 and still seeing some instances of this crash:
Screenshot 2023-12-10 at 13 48 44

Unfortunately no debugging information that I can provide easily. We have a fair number of active users, so the rate is definitely low.

@firebase firebase locked and limited conversation to collaborators Dec 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants