{"record":{"id":"84a8e99ec437afaa","repo":"google-gemini/gemini-cli","slug":"unsupported-authtype-authtype","errorCode":null,"errorMessage":"Unsupported authType: ${authType}","messagePattern":"Unsupported authType: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/code_assist/codeAssist.ts","lineNumber":39,"sourceCode":"  if (\n    authType === AuthType.LOGIN_WITH_GOOGLE ||\n    authType === AuthType.COMPUTE_ADC\n  ) {\n    const authClient = await getOauthClient(authType, config);\n    const userData = await setupUser(authClient, config, httpOptions);\n    return new CodeAssistServer(\n      authClient,\n      userData.projectId,\n      httpOptions,\n      sessionId,\n      userData.userTier,\n      userData.userTierName,\n      userData.paidTier,\n      config,\n    );\n  }\n\n  throw new Error(`Unsupported authType: ${authType}`);\n}\n\nexport function getCodeAssistServer(\n  config: Config,\n): CodeAssistServer | undefined {\n  let server = config.getContentGenerator();\n\n  // Recursively unwrap LoggingContentGenerator and ModelMappingContentGenerator\n  while (true) {\n    if (server instanceof LoggingContentGenerator) {\n      server = server.getWrapped();\n    } else if (server instanceof ModelMappingContentGenerator) {\n      server = server.getWrapped();\n    } else {\n      break;\n    }\n  }\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/core/src/code_assist/codeAssist.ts#L21-L57","documentation":"Thrown by createCodeAssistContentGenerator() when the authType argument is neither AuthType.LOGIN_WITH_GOOGLE nor AuthType.COMPUTE_ADC. This factory function builds a ContentGenerator backed by Google's Code Assist API and only supports those two OAuth-based authentication strategies. Any other auth type (e.g., USE_GEMINI, USE_VERTEX_AI, or an API key mode) is structurally incompatible with Code Assist and is rejected.","triggerScenarios":"Calling createCodeAssistContentGenerator(httpOptions, authType, config) with an authType value outside {LOGIN_WITH_GOOGLE, COMPUTE_ADC}. This commonly occurs when the auth resolution logic passes through an unexpected AuthType enum value.","commonSituations":"Configuration selects a non-OAuth auth method (e.g., GEMINI_API_KEY) but the code path still reaches createCodeAssistContentGenerator; a new AuthType enum value was added without updating this factory; the caller doesn't check authType before invoking the factory; testing with a mock authType value.","solutions":["Verify the authType before calling: only invoke createCodeAssistContentGenerator for LOGIN_WITH_GOOGLE or COMPUTE_ADC.","Route other auth types to their appropriate content generator factories (e.g., Gemini API key path).","If a new AuthType was added, extend this function's conditional or add a dedicated factory branch.","Check the Config.getAuthType() resolution logic to confirm it returns the expected value."],"exampleFix":"// before — unconditional call\nconst gen = await createCodeAssistContentGenerator(httpOpts, config.getAuthType(), config);\n\n// after — guard by auth type\nconst authType = config.getAuthType();\nif (authType !== AuthType.LOGIN_WITH_GOOGLE && authType !== AuthType.COMPUTE_ADC) {\n  throw new Error(`Code Assist requires OAuth auth, got ${authType}`);\n}\nconst gen = await createCodeAssistContentGenerator(httpOpts, authType, config);","handlingStrategy":"type-guard","validationCode":"// Check auth type before calling the factory\nconst authType = config.getAuthType();\nif (authType !== AuthType.LOGIN_WITH_GOOGLE && authType !== AuthType.COMPUTE_ADC) {\n  throw new Error(`Code Assist requires OAuth auth (LOGIN_WITH_GOOGLE or COMPUTE_ADC), got ${authType}`);\n}\nconst gen = await createCodeAssistContentGenerator(httpOptions, authType, config);","typeGuard":"function isCodeAssistAuthType(authType: AuthType): authType is typeof AuthType.LOGIN_WITH_GOOGLE | typeof AuthType.COMPUTE_ADC {\n  return authType === AuthType.LOGIN_WITH_GOOGLE || authType === AuthType.COMPUTE_ADC;\n}","tryCatchPattern":"try {\n  gen = await createCodeAssistContentGenerator(httpOptions, authType, config);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unsupported authType')) {\n    // Route to the appropriate content generator for the actual auth type\n    gen = await createAlternativeContentGenerator(authType, config);\n  } else throw e;\n}","preventionTips":["Centralize auth-type-to-factory routing in a single dispatcher function.","Add an exhaustive switch on AuthType to catch new enum values at compile time.","Unit test every AuthType value against the factory dispatcher.","Document which auth types are compatible with Code Assist."],"tags":["code-assist","authentication","content-generator","configuration"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}