Skip to content

Improve auth setup project-creation error handling and retry UX#95

Open
mkh09353 wants to merge 2 commits intogoogleworkspace:mainfrom
mkh09353:fix/setup-project-create-error-recovery
Open

Improve auth setup project-creation error handling and retry UX#95
mkh09353 wants to merge 2 commits intogoogleworkspace:mainfrom
mkh09353:fix/setup-project-create-error-recovery

Conversation

@mkh09353
Copy link

@mkh09353 mkh09353 commented Mar 5, 2026

Summary

Improve gws auth setup UX in two areas:

  1. Step 3 project creation recovery:
    • Keep the interactive wizard open when gcloud projects create fails.
    • Re-prompt for a new project ID instead of exiting immediately.
    • Add targeted guidance for common failure cases:
      • Google Cloud Terms of Service precondition (FAILED_PRECONDITION / type: TOS)
      • Invalid project ID format
      • Project ID already in use
  2. Setup success continuation:
    • Add gws auth setup --login to automatically continue into gws auth login.
    • In interactive terminal runs, prompt on success: Run gws auth login now? [Y/n].

Why

Users were hitting recoverable setup errors and having to restart the entire flow. Also, successful setup ending immediately felt abrupt and required an extra manual command.

Testing

  1. cargo clippy -- -D warnings
  2. cargo test

Both pass locally.

@changeset-bot
Copy link

changeset-bot bot commented Mar 5, 2026

🦋 Changeset detected

Latest commit: b4de4ab

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-cla
Copy link

google-cla bot commented Mar 5, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the user experience during the gws auth setup process by making project creation more resilient to errors. Instead of abruptly terminating, the setup wizard now intelligently detects common failure modes, provides clear, actionable advice, and allows users to correct issues and retry without restarting the entire process. This reduces friction and improves the overall flow for first-time setup.

Highlights

  • Improved Project Creation Error Handling: The interactive setup wizard (gws auth setup) now remains open and re-prompts for a new project ID instead of exiting immediately when project creation fails.
  • Targeted Error Guidance: Specific guidance is provided for common project creation failures, including Google Cloud Terms of Service not accepted, invalid project ID formats, and project IDs already in use.
  • Fallback Error Output: Helpful fallback output is preserved for unknown gcloud failures, ensuring users still receive relevant information.
Changelog
  • @googleworkspace/cli
    • Improve gws auth setup project creation failures in step 3:
    • Detect Google Cloud Terms of Service precondition failures and show actionable guidance (gcloud auth list, account verification, Console ToS URL).
    • Detect invalid project ID format / already-in-use errors and show clearer guidance.
    • In interactive setup, keep the wizard open and re-prompt for a new project ID instead of exiting immediately on create failures.
Activity
  • All 374 existing tests passed successfully, indicating no regressions were introduced by these changes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@mkh09353 mkh09353 force-pushed the fix/setup-project-create-error-recovery branch from 0d7885a to 542bae0 Compare March 5, 2026 03:54
@mkh09353 mkh09353 force-pushed the fix/setup-project-create-error-recovery branch from 542bae0 to ea5ed6b Compare March 5, 2026 03:54
Copy link
Contributor

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

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 significantly improves the user experience of the gws auth setup command by enhancing error handling during GCP project creation. It introduces a retry loop, allowing users to correct invalid project IDs without restarting the setup wizard, and provides more specific, actionable guidance for common failure scenarios like unaccepted Terms of Service or invalid/used project IDs. The changes are well-structured and include corresponding unit tests. I've suggested a small refinement to the error classification to make the user-facing messages even more accurate.

Comment on lines +625 to +627
lower.contains("argument project_id: bad value")
|| lower.contains("project ids are immutable")
|| lower.contains("project ids must be between 6 and 30 characters")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The error condition project ids are immutable is not a project ID format validation error. It's more related to the ID being in a reserved state (e.g., from a recently deleted project). Grouping this with format validation errors can lead to a confusing message for the user. This check should be moved to is_project_id_in_use_error to provide more accurate feedback.

Suggested change
lower.contains("argument project_id: bad value")
|| lower.contains("project ids are immutable")
|| lower.contains("project ids must be between 6 and 30 characters")
lower.contains("argument project_id: bad value")
|| lower.contains("project ids must be between 6 and 30 characters")

Comment on lines +632 to +634
lower.contains("already in use")
|| lower.contains("already exists")
|| lower.contains("already being used")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To provide a more accurate error message, the project ids are immutable check (moved from is_invalid_project_id_error) should be included here. This error is more akin to the project ID being already in use or reserved.

    lower.contains("already in use")
        || lower.contains("already exists")
        || lower.contains("already being used")
        || lower.contains("project ids are immutable")

@mkh09353 mkh09353 force-pushed the fix/setup-project-create-error-recovery branch from f70d1a8 to b4de4ab Compare March 5, 2026 04:16
@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

❌ Patch coverage is 49.77578% with 112 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.00%. Comparing base (99a6284) to head (b4de4ab).
⚠️ Report is 40 commits behind head on main.

Files with missing lines Patch % Lines
src/setup.rs 50.22% 109 Missing ⚠️
src/auth_commands.rs 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #95      +/-   ##
==========================================
+ Coverage   54.95%   55.00%   +0.04%     
==========================================
  Files          37       37              
  Lines       12218    12407     +189     
==========================================
+ Hits         6715     6824     +109     
- Misses       5503     5583      +80     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpoehnelt
Copy link
Member

Some conflicts to resolve.

@jpoehnelt
Copy link
Member

sorry, more conflicts 😄

@jpoehnelt jpoehnelt added area: auth area: tui complexity: high Large or complex change, careful review needed labels Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: auth area: tui complexity: high Large or complex change, careful review needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants