{"record":{"id":"64c2bd360938b246","repo":"google-gemini/gemini-cli","slug":"user-requested-to-change-authentication-method","errorCode":null,"errorMessage":"User requested to change authentication method","messagePattern":"User requested to change authentication method","errorType":"exception","errorClass":"ChangeAuthRequestedError","httpStatus":null,"severity":"info","filePath":"packages/core/src/code_assist/setup.ts","lineNumber":198,"sourceCode":"        ...coreClientMetadata,\n        duetProject: projectId,\n      },\n    });\n\n    try {\n      validateLoadCodeAssistResponse(loadRes);\n      break;\n    } catch (e) {\n      if (e instanceof ValidationRequiredError && validationHandler) {\n        const intent = await validationHandler(\n          e.validationLink,\n          e.validationDescription,\n        );\n        if (intent === 'verify') {\n          continue;\n        }\n        if (intent === 'change_auth') {\n          throw new ChangeAuthRequestedError();\n        }\n        throw new ValidationCancelledError();\n      }\n      throw e;\n    }\n  }\n\n  if (loadRes.currentTier) {\n    if (!loadRes.paidTier?.id && !loadRes.currentTier.id) {\n      debugLogger.warn(\n        'Warning: Code Assist API did not return a user tier ID. Defaulting to STANDARD tier.',\n      );\n    }\n\n    if (!loadRes.cloudaicompanionProject) {\n      if (projectId) {\n        return {\n          projectId,","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/core/src/code_assist/setup.ts#L180-L216","documentation":"ChangeAuthRequestedError is a control-flow exception thrown inside setupUser's validation loop. It fires only after the Code Assist API returned ValidationRequiredError AND the caller's validationHandler returned the literal intent 'change_auth'. It is not a failure: it tells the outer auth layer to restart auth selection with a different credential.","triggerScenarios":"setupUser() -> caServer.loadCodeAssist() throws ValidationRequiredError -> config.getValidationHandler() is set -> user picks 'change_auth' from the verificationLink/validationDescription prompt -> line 198 throws.","commonSituations":"User selects 'Use a different account' / 'Switch login' in the OAuth/quota verification prompt; first-time login where the default account lacks Code Assist access; switching from Vertex to Code Assist auth.","solutions":["Catch ChangeAuthRequestedError at the auth-selection layer and loop back to credential choice (this is the intended handler).","If you did not mean to switch auth, retry setupUser and pick 'verify' on the validation prompt.","If the prompt keeps appearing, ensure the account is on a Code Assist-eligible tier before re-running."],"exampleFix":"// before\ntry { await setupUser(client, config); }\ncatch (e) { throw e; }\n// after\ntry { await setupUser(client, config); }\ncatch (e) {\n  if (e instanceof ChangeAuthRequestedError) { return restartAuthSelection(); }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"// node\nimport { ChangeAuthRequestedError } from './utils/errors.js';\nfunction isChangeAuthRequested(e: unknown): e is ChangeAuthRequestedError {\n  return e instanceof ChangeAuthRequestedError;\n}","tryCatchPattern":"try {\n  await setupUser(client, config);\n} catch (e) {\n  if (e instanceof ChangeAuthRequestedError) {\n    // intended: restart auth method selection\n    return restartAuthSelection();\n  }\n  throw e;\n}","preventionTips":["Always wire a validationHandler so user intent is mapped to one of 'verify' | 'change_auth'.","Treat ChangeAuthRequestedError as control flow, not a bug — never let it bubble to generic error UI."],"tags":["auth","control-flow","code-assist","typescript"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}