Skip to content

fix(firestore): add -f to databases:delete and clarify Firestore command help and errors - #11425

Draft
joehan wants to merge 6 commits into
mainfrom
joehan/cli-help-firestore
Draft

joehan wants to merge 6 commits into
mainfrom
joehan/cli-help-firestore

Conversation

@joehan

@joehan joehan commented Nov 3, 2026

Copy link
Copy Markdown
Member

Description

Parent Epic: Buganizer b/581483183 (Improve agent understanding of CLI behavior)
Resolves:

  • Buganizer b/581495249 (firestore:databases:create)
  • Buganizer b/581494831 (firestore:databases:get)
  • Buganizer b/581494832 (firestore:databases:update)
  • Buganizer b/581495582 (firestore:databases:delete)
  • Buganizer b/581493919 (firestore:delete)

Fixes --force / --non-interactive handling on firestore:databases:delete and clarifies --help defaults, output formats, and error messages across Cloud Firestore commands:

  • firestore:databases:create (src/commands/firestore-databases-create.ts): Fixes misleading unconditional "Default is 'ENABLED'" help text on --firestore-data-access and --realtime-updates, documenting their conditional Enterprise / MongoDB-compatibility defaults accurately.
  • firestore:databases:get (src/commands/firestore-databases-get.ts): Clarifies that [database] defaults to (default) and distinguishes the pretty-printed summary table fields from full metadata returned with --json.
  • firestore:databases:update (src/commands/firestore-databases-update.ts): Removes copy-pasted "create API call" / "Default is DISABLED" option help text (since omitted flags leave existing settings unchanged) and names --delete-protection and --point-in-time-recovery in the missing-flag error.
  • firestore:databases:delete (src/commands/firestore-databases-delete.ts): Replaces bespoke --option("--force", ...) and bare-string confirm() with standard .withForce() and confirm({ message, default: false, force, nonInteractive }) so -f works and --non-interactive fails cleanly with remediation instead of an unhandled prompt error.
  • firestore:delete (src/commands/firestore-delete.ts, src/firestore/delete.ts): Clarifies [path] vs. --all-collections and -r/--recursive vs. --shallow requirements in --help and error messages.

Scenarios Tested

  • npm run build and npm run test:compile: Passed with 0 errors.
  • npm run lint:quiet and prettier --check: Passed with 0 errors.
  • Unit tests (node_modules/.bin/mocha):
    • src/commands/firestore-databases-update.spec.ts
    • src/commands/firestore-databases-delete.spec.ts
    • src/commands/firestore-delete.spec.ts

Sample Commands

firebase firestore:databases:create --help
firebase firestore:databases:delete my-db -f
firebase firestore:databases:update --help

Remove false 'Default is DISABLED' claims (omitted settings are left
unchanged), list exact allowed values, drop redundant command-local
--json option with copy-pasted 'create API call' text (global --json
still applies), and name the required flags in the error message.
@joehan joehan self-assigned this Nov 3, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors and improves several Firestore CLI commands (databases:delete, databases:get, databases:update, and delete) by enhancing their descriptions, standardizing options (such as using withForce), clarifying error messages, and adding comprehensive unit tests. The review feedback correctly points out that several newly thrown FirebaseError instances for precondition violations should include the { exit: 1 } option to comply with the repository's style guide.

Comment on lines +27 to +31
if (!options.force && options.nonInteractive) {
throw new FirebaseError(
`Deleting ${databasePath} requires confirmation. Pass --force to delete the database in non-interactive mode.`,
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

According to the repository style guide, if an error is due to a violation of a precondition (such as requiring confirmation in non-interactive mode), we should specify a non-zero exit code ({ exit: 1 }) in the FirebaseError options.

    if (!options.force && options.nonInteractive) {
      throw new FirebaseError(
        `Deleting ${databasePath} requires confirmation. Pass --force to delete the database in non-interactive mode.`,
        { exit: 1 },
      );
    }
References
  1. Throw FirebaseError for expected, user-facing errors. If the error is due to a violation of a precondition, specify a non-zero exit code ({ exit: 1 }). (link)

Comment on lines 33 to 37
if (!options.deleteProtection && !options.pointInTimeRecovery) {
throw new FirebaseError(`Missing properties to update. ${helpCommandText}`);
throw new FirebaseError(
`Missing properties to update. Specify at least one of --delete-protection or --point-in-time-recovery. ${helpCommandText}`,
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

According to the repository style guide, if an error is due to a violation of a precondition (such as missing properties to update), we should specify a non-zero exit code ({ exit: 1 }) in the FirebaseError options.

Suggested change
if (!options.deleteProtection && !options.pointInTimeRecovery) {
throw new FirebaseError(`Missing properties to update. ${helpCommandText}`);
throw new FirebaseError(
`Missing properties to update. Specify at least one of --delete-protection or --point-in-time-recovery. ${helpCommandText}`,
);
}
if (!options.deleteProtection && !options.pointInTimeRecovery) {
throw new FirebaseError(
`Missing properties to update. Specify at least one of --delete-protection or --point-in-time-recovery. ${helpCommandText}`,
{ exit: 1 },
);
}
References
  1. Throw FirebaseError for expected, user-facing errors. If the error is due to a violation of a precondition, specify a non-zero exit code ({ exit: 1 }). (link)

Comment thread src/firestore/delete.ts
Comment on lines 136 to 146
if (this.recursive && this.shallow) {
throw new FirebaseError("Cannot pass recursive and shallow options together.");
throw new FirebaseError(
"Cannot pass recursive (-r, --recursive) and shallow (--shallow) options together.",
);
}

if (this.isCollectionPath && !this.recursive && !this.shallow) {
throw new FirebaseError("Must pass recursive or shallow option when deleting a collection.");
throw new FirebaseError(
"Must pass recursive (-r, --recursive) or shallow (--shallow) option when deleting a collection.",
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

According to the repository style guide, if an error is due to a violation of a precondition (such as mutually exclusive options or missing required options), we should specify a non-zero exit code ({ exit: 1 }) in the FirebaseError options.

Suggested change
if (this.recursive && this.shallow) {
throw new FirebaseError("Cannot pass recursive and shallow options together.");
throw new FirebaseError(
"Cannot pass recursive (-r, --recursive) and shallow (--shallow) options together.",
);
}
if (this.isCollectionPath && !this.recursive && !this.shallow) {
throw new FirebaseError("Must pass recursive or shallow option when deleting a collection.");
throw new FirebaseError(
"Must pass recursive (-r, --recursive) or shallow (--shallow) option when deleting a collection.",
);
}
if (this.recursive && this.shallow) {
throw new FirebaseError(
"Cannot pass recursive (-r, --recursive) and shallow (--shallow) options together.",
{ exit: 1 },
);
}
if (this.isCollectionPath && !this.recursive && !this.shallow) {
throw new FirebaseError(
"Must pass recursive (-r, --recursive) or shallow (--shallow) option when deleting a collection.",
{ exit: 1 },
);
}
References
  1. Throw FirebaseError for expected, user-facing errors. If the error is due to a violation of a precondition, specify a non-zero exit code ({ exit: 1 }). (link)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant