Skip to content

feat: better error messages#20577

Merged
gsquared94 merged 2 commits intogoogle-gemini:mainfrom
gsquared94:better-error-messages
Feb 27, 2026
Merged

feat: better error messages#20577
gsquared94 merged 2 commits intogoogle-gemini:mainfrom
gsquared94:better-error-messages

Conversation

@gsquared94
Copy link
Contributor

No description provided.

@gsquared94 gsquared94 requested a review from a team as a code owner February 27, 2026 16:58
@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 improves the clarity and actionability of authentication error messages within the CLI. By introducing a specific error type and a dedicated user interface for account suspensions, users will receive precise information and direct options (like appealing a suspension or changing authentication) when their access is restricted due to Terms of Service violations. This change enhances the overall user experience by moving beyond generic error messages to provide targeted support for critical authentication issues.

Highlights

  • Enhanced Authentication Error Handling: The system now specifically identifies and processes account suspension errors (TOS_VIOLATION) during the initial authentication flow.
  • New AccountSuspendedError Type: A dedicated error class AccountSuspendedError has been introduced in the core utility library to encapsulate details about account suspensions, including appeal URLs.
  • Dedicated UI for Suspended Accounts: A new BannedAccountDialog component provides a user-friendly interface to display suspension messages, appeal links, and options to change authentication or exit.
  • Updated Authentication Flow: The performInitialAuth function now returns a comprehensive InitialAuthResult object, containing both general authentication errors and specific account suspension information.
  • Integration Across CLI Components: Various CLI components, including initializeApp, useAuthCommand, and DialogManager, have been updated to correctly handle and display the new account suspension state.
Changelog
  • packages/cli/src/core/auth.test.ts
    • Updated authentication test expectations to match the new InitialAuthResult structure and added a test case for TOS_VIOLATION errors.
  • packages/cli/src/core/auth.ts
    • Modified performInitialAuth to return an InitialAuthResult object, incorporating authError and accountSuspensionInfo, and integrated isAccountSuspendedError for specific error detection.
  • packages/cli/src/core/initializer.test.ts
    • Adjusted tests for initializeApp to align with the updated return type of performInitialAuth.
  • packages/cli/src/core/initializer.ts
    • Updated initializeApp to destructure authError and accountSuspensionInfo from the authentication result and extended the InitializationResult interface.
  • packages/cli/src/gemini.test.tsx
    • Modified mockInitializationResult to include the new accountSuspensionInfo property.
  • packages/cli/src/test-utils/AppRig.tsx
    • Updated the useAuth mock and initializationResult to support accountSuspensionInfo and its setter.
  • packages/cli/src/test-utils/render.tsx
    • Added clearAccountSuspension to the mockUIActions object.
  • packages/cli/src/ui/AppContainer.tsx
    • Updated the useAuthCommand hook call to pass accountSuspensionInfo and integrated clearAccountSuspension into the UIActionsContext.
  • packages/cli/src/ui/auth/BannedAccountDialog.test.tsx
    • Added a new test file to thoroughly test the BannedAccountDialog component's rendering, interaction, and error handling.
  • packages/cli/src/ui/auth/BannedAccountDialog.tsx
    • Implemented a new React component BannedAccountDialog to display account suspension details, including appeal URLs, and provide interactive options.
  • packages/cli/src/ui/auth/snapshots/BannedAccountDialog.test.tsx.snap
    • Added a snapshot for the BannedAccountDialog component's rendered output.
  • packages/cli/src/ui/auth/useAuth.ts
    • Enhanced the useAuthCommand hook to manage accountSuspensionInfo state and to detect and handle AccountSuspendedError during the authentication process.
  • packages/cli/src/ui/components/DialogManager.tsx
    • Integrated the BannedAccountDialog into the DialogManager to ensure it is displayed when an account suspension is detected.
  • packages/cli/src/ui/contexts/UIActionsContext.tsx
    • Extended the UIActions interface with a clearAccountSuspension method.
  • packages/cli/src/ui/contexts/UIStateContext.tsx
    • Defined the AccountSuspensionInfo interface and added accountSuspensionInfo to the UIState interface.
  • packages/core/src/utils/errors.test.ts
    • Added new test cases for toFriendlyError to verify correct identification and parsing of TOS_VIOLATION errors into AccountSuspendedError.
  • packages/core/src/utils/errors.ts
    • Introduced the AccountSuspendedError class, updated toFriendlyError to specifically parse Google API errors for TOS_VIOLATION details, and added the isAccountSuspendedError utility function.
Activity
  • The pull request introduces a new feature for handling account suspension errors.
  • New UI components and error handling logic have been added.
  • Existing authentication and initialization flows have been updated to support the new error reporting mechanism.
  • Comprehensive unit tests have been added for the new UI component and updated for modified core logic.
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.

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 introduces improved error handling for account suspension scenarios. It adds a new AccountSuspendedError type in the core package to specifically identify TOS violation errors from the API. This information is then propagated up to the CLI's UI layer, which now displays a BannedAccountDialog to the user. This dialog informs the user about the suspension and provides options to appeal, change authentication method, or exit. The changes are well-structured, with clear separation of concerns between the core error handling and the UI presentation. The implementation is robust, handling various states and edge cases, and is accompanied by thorough unit tests for the new components and logic. Overall, this is a solid feature implementation.

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 27, 2026
@gsquared94 gsquared94 enabled auto-merge February 27, 2026 17:52
@gsquared94 gsquared94 force-pushed the better-error-messages branch from 1ac3072 to da02732 Compare February 27, 2026 17:52
@gsquared94 gsquared94 force-pushed the better-error-messages branch from da02732 to 2c0589e Compare February 27, 2026 18:00
@gsquared94 gsquared94 added this pull request to the merge queue Feb 27, 2026
Merged via the queue into google-gemini:main with commit ea48bd9 Feb 27, 2026
27 checks passed
@gsquared94 gsquared94 deleted the better-error-messages branch February 27, 2026 18:33
@galz10
Copy link
Collaborator

galz10 commented Feb 27, 2026

/patch release

@github-actions
Copy link

Patch workflow(s) dispatched successfully!

📋 Details:

  • Channels: stable,preview
  • Commit: ea48bd9414a0e1de735933211680dcced3731946
  • Workflows Created: 2

🔗 Track Progress:

github-actions bot pushed a commit that referenced this pull request Feb 27, 2026
Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
# Conflicts:
#	packages/cli/src/test-utils/render.tsx
#	packages/cli/src/ui/AppContainer.tsx
#	packages/cli/src/ui/contexts/UIActionsContext.tsx
#	packages/core/src/utils/errors.test.ts
#	packages/core/src/utils/errors.ts
@github-actions
Copy link

🚀 Patch PR Created!

📋 Patch Details:

📝 Next Steps:

  1. ⚠️ Resolve conflicts in the hotfix PR first: #20591
  2. Test your changes after resolving conflicts
  3. Once merged, the patch release will automatically trigger
  4. You'll receive updates here when the release completes

🔗 Track Progress:

github-actions bot pushed a commit that referenced this pull request Feb 27, 2026
Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
# Conflicts:
#	packages/cli/src/test-utils/render.tsx
#	packages/cli/src/ui/AppContainer.tsx
#	packages/cli/src/ui/contexts/UIActionsContext.tsx
@github-actions
Copy link

🚀 Patch PR Created!

📋 Patch Details:

📝 Next Steps:

  1. ⚠️ Resolve conflicts in the hotfix PR first: #20592
  2. Test your changes after resolving conflicts
  3. Once merged, the patch release will automatically trigger
  4. You'll receive updates here when the release completes

🔗 Track Progress:

@github-actions
Copy link

🚀 Patch Release Started!

📋 Release Details:

  • Environment: prod
  • Channel: preview → publishing to npm tag preview
  • Version: v0.31.0-preview.1
  • Hotfix PR: Merged ✅
  • Release Branch: release/v0.31.0-preview.1-pr-20577

⏳ Status: The patch release is now running. You'll receive another update when it completes.

🔗 Track Progress:

@github-actions
Copy link

Patch Release Complete!

📦 Release Details:

🎉 Status: Your patch has been successfully released and published to npm!

📝 What's Available:

🔗 Links:

BryanBradfo pushed a commit to BryanBradfo/gemini-cli that referenced this pull request Mar 5, 2026
Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants