-
Notifications
You must be signed in to change notification settings - Fork 410
fix: Invalid provider UID handling in federated user lookup #3034
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1397,10 +1397,10 @@ AUTH_CONFIGS.forEach((testConfig) => { | |||||
| .with.property('code', 'auth/invalid-provider-id'); | ||||||
| }); | ||||||
|
|
||||||
| it('should be rejected given an invalid provider uid', () => { | ||||||
| it('should be rejected given an invalid uid', () => { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test description was changed from "should be rejected given an invalid provider uid" to "should be rejected given an invalid uid". The former is more descriptive and less ambiguous, as "uid" could be misinterpreted as the Firebase user UID, whereas this test is specifically for the provider-specific UID. I suggest reverting to the more specific description to improve test clarity.
Suggested change
|
||||||
| expect(() => auth.getUserByProviderUid('id', '')) | ||||||
| .to.throw(FirebaseAuthError) | ||||||
| .with.property('code', 'auth/invalid-provider-id'); | ||||||
| .with.property('code', 'auth/invalid-uid'); | ||||||
| }); | ||||||
|
|
||||||
| it('should be rejected given an app which returns null access tokens', () => { | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change correctly throws a more specific
INVALID_UIDerror for an emptyrawId, aligning withvalidateProviderUserInfoas mentioned in the pull request description. However, there seems to be another inconsistency in the codebase. TheaddProviderToRequestfunction (line 1051) throwsAuthClientErrorCode.INVALID_PROVIDER_UIDfor an emptyproviderUid. This function is used bygetUsers().This means
auth.getUserByProviderUid('a', '')will throwauth/invalid-uid, whileauth.getUsers([{providerId: 'a', providerUid: ''}])will throwauth/invalid-provider-uid.While fixing this might be outside the scope of this PR, it would be good to create a follow-up issue to make these error codes consistent across the API for a better developer experience.