fix(patch): cherry-pick ea48bd9 to release/v0.30.1-pr-20577 [CONFLICTS]#20591
Conversation
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
Summary of ChangesHello, 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 backports a critical enhancement to the CLI's authentication system. It improves the user experience by providing more specific feedback when an account is suspended, guiding users towards resolution through a new interactive dialog. This change ensures that users encountering account suspension issues are clearly informed and presented with actionable steps, rather than a generic authentication failure. Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request cherry-picks changes to handle account suspension errors, specifically for "Terms of Service" violations. The changes introduce a new BannedAccountDialog to inform the user and provide options to appeal or change authentication. The authentication flow and related types have been updated to carry accountSuspensionInfo.
However, the cherry-pick has resulted in several unresolved merge conflicts across multiple files. These conflicts contain <<<<<<< HEAD, =======, and >>>>>>> markers, which will prevent the code from compiling and must be resolved. Critical comments have been added to each file where these conflicts are present.
| <<<<<<< HEAD | ||
| ======= | ||
| getPreferredEditor: vi.fn(), | ||
| clearAccountSuspension: vi.fn(), | ||
| }; | ||
|
|
||
| let capturedOverflowState: OverflowState | undefined; | ||
| let capturedOverflowActions: OverflowActions | undefined; | ||
| const ContextCapture: React.FC<{ children: React.ReactNode }> = ({ | ||
| children, | ||
| }) => { | ||
| capturedOverflowState = useOverflowState(); | ||
| capturedOverflowActions = useOverflowActions(); | ||
| return <>{children}</>; | ||
| >>>>>>> ea48bd941 (feat: better error messages (#20577)) | ||
| }; |
packages/cli/src/ui/AppContainer.tsx
Outdated
| <<<<<<< HEAD | ||
| ======= | ||
| getPreferredEditor, | ||
| clearAccountSuspension: () => { | ||
| setAccountSuspensionInfo(null); | ||
| setAuthState(AuthState.Updating); | ||
| }, | ||
| >>>>>>> ea48bd941 (feat: better error messages (#20577)) |
| <<<<<<< HEAD | ||
| ======= | ||
| getPreferredEditor: () => EditorType | undefined; | ||
| clearAccountSuspension: () => void; | ||
| >>>>>>> ea48bd941 (feat: better error messages (#20577)) |
| <<<<<<< HEAD | ||
| ======= | ||
|
|
||
| describe('getErrorType', () => { | ||
| it('should return error name for standard errors', () => { | ||
| expect(getErrorType(new Error('test'))).toBe('Error'); | ||
| expect(getErrorType(new TypeError('test'))).toBe('TypeError'); | ||
| expect(getErrorType(new SyntaxError('test'))).toBe('SyntaxError'); | ||
| }); | ||
|
|
||
| it('should return constructor name for custom errors', () => { | ||
| expect(getErrorType(new FatalAuthenticationError('test'))).toBe( | ||
| 'FatalAuthenticationError', | ||
| ); | ||
| expect(getErrorType(new FatalInputError('test'))).toBe('FatalInputError'); | ||
| expect(getErrorType(new FatalSandboxError('test'))).toBe( | ||
| 'FatalSandboxError', | ||
| ); | ||
| expect(getErrorType(new FatalConfigError('test'))).toBe('FatalConfigError'); | ||
| expect(getErrorType(new FatalTurnLimitedError('test'))).toBe( | ||
| 'FatalTurnLimitedError', | ||
| ); | ||
| expect(getErrorType(new FatalToolExecutionError('test'))).toBe( | ||
| 'FatalToolExecutionError', | ||
| ); | ||
| expect(getErrorType(new FatalCancellationError('test'))).toBe( | ||
| 'FatalCancellationError', | ||
| ); | ||
| expect(getErrorType(new ForbiddenError('test'))).toBe('ForbiddenError'); | ||
| expect(getErrorType(new AccountSuspendedError('test'))).toBe( | ||
| 'AccountSuspendedError', | ||
| ); | ||
| expect(getErrorType(new UnauthorizedError('test'))).toBe( | ||
| 'UnauthorizedError', | ||
| ); | ||
| expect(getErrorType(new BadRequestError('test'))).toBe('BadRequestError'); | ||
| }); | ||
|
|
||
| it('should return "unknown" for non-Error objects', () => { | ||
| expect(getErrorType('string error')).toBe('unknown'); | ||
| expect(getErrorType(123)).toBe('unknown'); | ||
| expect(getErrorType({})).toBe('unknown'); | ||
| expect(getErrorType(null)).toBe('unknown'); | ||
| expect(getErrorType(undefined)).toBe('unknown'); | ||
| }); | ||
| }); | ||
| >>>>>>> ea48bd941 (feat: better error messages (#20577)) |
packages/core/src/utils/errors.ts
Outdated
| <<<<<<< HEAD | ||
| if (error && typeof error === 'object' && 'response' in error) { | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion | ||
| const gaxiosError = error as GaxiosError; | ||
| const data = parseResponseData(gaxiosError); | ||
| ======= | ||
| // First, try structured parsing for TOS_VIOLATION detection. | ||
| const googleApiError = parseGoogleApiError(error); | ||
| if (googleApiError && googleApiError.code === 403) { | ||
| const tosDetail = googleApiError.details.find( | ||
| (d): d is ErrorInfo => | ||
| d['@type'] === 'type.googleapis.com/google.rpc.ErrorInfo' && | ||
| 'reason' in d && | ||
| d.reason === 'TOS_VIOLATION', | ||
| ); | ||
| if (tosDetail) { | ||
| return new AccountSuspendedError( | ||
| googleApiError.message, | ||
| tosDetail.metadata, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // Fall back to basic Gaxios error parsing for other HTTP errors. | ||
| if (isGaxiosError(error)) { | ||
| const data = parseResponseData(error); | ||
| >>>>>>> ea48bd941 (feat: better error messages (#20577)) |
|
Size Change: +7.11 kB (+0.03%) Total Size: 24.5 MB
ℹ️ View Unchanged
|
This PR automatically cherry-picks commit ea48bd9 to patch version v0.30.1 in the stable release to create version 0.30.2.
This cherry-pick resulted in merge conflicts that need manual resolution.
🔧 Next Steps:
📋 Files with conflicts:
The commit has been created with conflict markers for easier manual resolution.
🚨 Important: