Fix errors showing as success in Firestore commands #7482
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Firestore commands often log and then return. This works fine for normal commands, but when using
--jsonmode it will printsuccessto the terminal even though it early exited with an error. Replacing these logs with FirebaseErrors.Before change:
After change:
Note: This is the same PR as #7474 but not using a fork.
Scenarios Tested
All failure scenarios tested for the changed commands.
Click to see all test output
firestore:backups:schedules:create
$ firebase firestore:backups:schedules:create --json { "status": "error", "error": "Missing required flag --retention. See firebase firestore:backups:schedules:create --help for more info." } Having trouble? Try firebase [command] --help $ firebase firestore:backups:schedules:create --json --retention error: option '-rt, --retention <duration>' argument missing # retention $ firebase firestore:backups:schedules:create --json --retention 1s { "status": "error", "error": "\"retention\" flag must be a duration string (e.g. 24h, 2w, or 7d)" } Having trouble? Try firebase [command] --help $ firebase firestore:backups:schedules:create --json --retention 2w { "status": "error", "error": "Missing required flag --recurrence. See firebase firestore:backups:schedules:create --help for more info." } Having trouble? Try firebase [command] --help # recurrence $ firebase firestore:backups:schedules:create --json --retention 2w --recurrence error: option '-rc, --recurrence <recurrence>' argument missing $ firebase firestore:backups:schedules:create --json --retention 2w --recurrence M { "status": "error", "error": "Invalid value for flag --recurrence. See firebase firestore:backups:schedules:create --help for more info." } Having trouble? Try firebase [command] --help $ firebase firestore:backups:schedules:create --json --retention 2w --recurrence WEEKLY { "status": "error", "error": "If --recurrence is WEEKLY, --day-of-week must be provided. See firebase firestore:backups:schedules:create --help for more info." } Having trouble? Try firebase [command] --help # day-of-week $ firebase firestore:backups:schedules:create --json --retention 2w --recurrence WEEKLY --day-of-week error: option '-dw, --day-of-week <dayOfWeek>' argument missing $ firebase firestore:backups:schedules:create --json --retention 2w --recurrence WEEKLY --day-of-week MON { "status": "error", "error": "HTTP Error: 400, Invalid value at 'backup_schedule.weekly_recurrence.day' (type.googleapis.com/google.type.DayOfWeek), \"MON\"" } Having trouble? Try firebase [command] --help $ firebase firestore:backups:schedules:create --json --retention 2w --recurrence DAILY --day-of-week MONDAY { "status": "error", "error": "--day-of-week should not be provided if --recurrence is DAILY. See firebase firestore:backups:schedules:create --help for more info." } Having trouble? Try firebase [command] --help # Success $ firebase firestore:backups:schedules:create --json --retention 2w --recurrence DAILY $ firebase firestore:backups:schedules:create --json --retention 2w --recurrence WEEKLY --day-of-week MONDAYfirestore:backups:schedules:update
firestore:databases:create
firestore:databases:restore
$ firebase firestore:databases:restore --json { "status": "error", "error": "Missing required flag --database. See firebase firestore:databases:restore --help for more info." } Having trouble? Try firebase [command] --help # database $ firebase firestore:databases:restore --json --database error: option '-d, --database <databaseID>' argument missing $ firebase firestore:databases:restore --json --database database { "status": "error", "error": "Missing required flag --backup. See firebase firestore:databases:restore --help for more info." } Having trouble? Try firebase [command] --help # backup $ firebase firestore:databases:restore --json --database database --backup error: option '-b, --backup <backup>' argument missing # Success $ firebase firestore:databases:restore --json --database database --backup backupfirestore:databases:update
Sample Commands
No changes to commands, only error output.