fix(patch): cherry-pick 87a0db2 to release/v0.25.0-pr-17308 [CONFLICTS] (#17316)

Co-authored-by: Shreya Keshive <shreyakeshive@google.com>
This commit is contained in:
gemini-cli-robot
2026-01-22 10:31:29 -08:00
committed by GitHub
parent c9dbf70043
commit 2a8e1a8cc1
2 changed files with 8 additions and 2 deletions

View File

@@ -1065,6 +1065,8 @@ describe('gemini.tsx main function exit codes', () => {
vi.mocked(loadSandboxConfig).mockResolvedValue({} as any);
vi.mocked(loadCliConfig).mockResolvedValue({
refreshAuth: vi.fn().mockRejectedValue(new Error('Auth failed')),
getRemoteAdminSettings: vi.fn().mockReturnValue(undefined),
isInteractive: vi.fn().mockReturnValue(true),
} as unknown as Config);
vi.mocked(loadSettings).mockReturnValue({
merged: {

View File

@@ -363,6 +363,7 @@ export async function main() {
// Refresh auth to fetch remote admin settings from CCPA and before entering
// the sandbox because the sandbox will interfere with the Oauth2 web
// redirect.
let initialAuthFailed = false;
if (
settings.merged.security?.auth?.selectedType &&
!settings.merged.security?.auth?.useExternal
@@ -390,8 +391,7 @@ export async function main() {
}
} catch (err) {
debugLogger.error('Error authenticating:', err);
await runExitCleanup();
process.exit(ExitCodes.FATAL_AUTHENTICATION_ERROR);
initialAuthFailed = true;
}
}
@@ -414,6 +414,10 @@ export async function main() {
// another way to decouple refreshAuth from requiring a config.
if (sandboxConfig) {
if (initialAuthFailed) {
await runExitCleanup();
process.exit(ExitCodes.FATAL_AUTHENTICATION_ERROR);
}
let stdinData = '';
if (!process.stdin.isTTY) {
stdinData = await readStdin();