-
Notifications
You must be signed in to change notification settings - Fork 970
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
Fix export users #1690
Fix export users #1690
Conversation
@kossnocorp thanks for your contribution! Assigning this one to @bkendall who reviewed code on this path recently. |
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 looks like a reasonable fix to me. Thanks for the PR. A couple things to clean up in the test, but should be easy enough.
Please also
- Sync with
master
- Add an entry to
CHANGELOG.md
, maybe:
* Fixes invalid JSON output in `auth.export` within a scripting environment.
@bkendall thank you for the review, I'll address that. |
When `serialExportUsers` function is called more than once, it adds a redundant comma, which breaks the JSON format. The first call: ``` {"users": [ { "localId": "DxADx87BFyPe8HhD4dOAyuwXECu1", ... ``` The second call (and all consecutive): ``` {"users": [ , { "localId": "DxADx87BFyPe8HhD4dOAyuwXECu1", ... ```
When `serialExportUsers` function is called more than once, it adds a redundant comma, which breaks the JSON format. The bug is caused by a global variable `jsonSep` in an internal `_writeUsersToFile` function. I assume that it was first introduced to make JSON streamable. I changed the code to make it generate `writeUsersToFile` shared among recursive calls.
Thanks for the PR! |
* master: change out tslint for eslint, new publish config (firebase#486) Remove scripts/package.json and update firebase version. (firebase#1704) Fix functions deploy integration test script (firebase#1703) Loop the modules properties without prototype methods. Fixes firebase#1687 (firebase#1694) Allow customers to configure the db setting 'strictTriggerValidation' (firebase#1702) [firebase-release] Removed change log and reset repo after 7.5.0 release 7.5.0 Fix export users (firebase#1690) Fix port issues in WSL (firebase#1699) Unremove but deprecate separate port for WebChannel. (firebase#1698) Release Firestore Emulator 1.9.0 and remove WebChannel workaround. (firebase#1689) update handlebars dependency (firebase#1686) [firebase-release] Removed change log and reset repo after 7.4.0 release 7.4.0 remove items from previews list (firebase#488)
You're very welcome, thank you for a great platform! |
Description
This PR fixes a bug in
auth.export
command. WhenserialExportUsers
function (used by the command) is called more than once, it adds a redundant comma, which breaks the JSON format.The first call:
The second call (and all consecutive):
The bug is caused by a global variable
jsonSep
in an internal_writeUsersToFile
function. I assume that it was first introduced to make JSON streamable.I changed the code to make it generate
writeUsersToFile
shared among recursive calls.Scenarios Tested
When the package is used via Node.js API:
Always produce valid JSON. Before the changes, the second
tools.auth.export
call produces malformed JSON (see the,
as the first array element):