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

Auth user import doesn't seem to work #4157

Closed
vthommeret opened this issue Feb 12, 2022 · 1 comment · Fixed by #4172
Closed

Auth user import doesn't seem to work #4157

vthommeret opened this issue Feb 12, 2022 · 1 comment · Fixed by #4172
Assignees

Comments

@vthommeret
Copy link

[REQUIRED] Environment info

firebase-tools: 10.1.4

Platform: macOS

[REQUIRED] Steps to reproduce

firebase auth:import users.json

[REQUIRED] Expected behavior

Successful import.

[REQUIRED] Actual behavior

Two issues. One is that no error details are actually displayed:

Processing users.json (9500 bytes)                                                                                                    
Starting importing 27 account(s).                                                                                                                             
Encountered problems while importing accounts. Details:                                                                                                       
                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                              

Digging into the code, it seems like this line isn't logging the error:

I don't know the details of how Firebase logging works, but when I switched it to console.log for debugging purposes I then saw these errors:

[                                                                                                                                                             
  { index: 0, message: 'localId is missing' },                                                                                                                
  { index: 1, message: 'localId is missing' },                                                                                                                
  { index: 2, message: 'localId is missing' },                                                                                                                
  { index: 3, message: 'localId is missing' },                                                                                                                
  { index: 4, message: 'localId is missing' },                                                                                                                
  { index: 5, message: 'localId is missing' },                                                                                                                
  { index: 6, message: 'localId is missing' },                                                                                                                
  { index: 7, message: 'localId is missing' }, 
  . . .

Looking at my specific file localId was specified (I got it via the corresponding auth export command). Digging it appears that this section of code is the issue:

const user = validateUserJson(value);
// TODO: Remove this casst once user can have an error.
const err = (user as any).error;
if (err) {
throw new FirebaseError(`Validation Error: ${err}`);
}
currentBatch.push(user);

Specifically, it calls validateUserJson which returns an empty object if there are no validation errors. But this value is used as the user, so each "user" is just an empty object which get rejected by the API. By switching the code to push value instead of the user value: currentBatch.push(value), I was able to successfully import my auth users:

Starting importing 27 account(s).
✔  Imported successfully.

cc @bkendall It seems possibly introduced by this change b705926

@vthommeret vthommeret added the bug label Feb 12, 2022
@google-oss-bot
Copy link
Contributor

This issue does not seem to follow the issue template. Make sure you provide all the required information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants