google-gemini/gemini-cli · error · Error
Unsupported authType: ${authType}
Error message
Unsupported authType: ${authType} What it means
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.
Source
Thrown at packages/core/src/code_assist/codeAssist.ts:39
if (
authType === AuthType.LOGIN_WITH_GOOGLE ||
authType === AuthType.COMPUTE_ADC
) {
const authClient = await getOauthClient(authType, config);
const userData = await setupUser(authClient, config, httpOptions);
return new CodeAssistServer(
authClient,
userData.projectId,
httpOptions,
sessionId,
userData.userTier,
userData.userTierName,
userData.paidTier,
config,
);
}
throw new Error(`Unsupported authType: ${authType}`);
}
export function getCodeAssistServer(
config: Config,
): CodeAssistServer | undefined {
let server = config.getContentGenerator();
// Recursively unwrap LoggingContentGenerator and ModelMappingContentGenerator
while (true) {
if (server instanceof LoggingContentGenerator) {
server = server.getWrapped();
} else if (server instanceof ModelMappingContentGenerator) {
server = server.getWrapped();
} else {
break;
}
}
View on GitHub (pinned to 5024443c72)
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.
Example fix
// before — unconditional call
const gen = await createCodeAssistContentGenerator(httpOpts, config.getAuthType(), config);
// after — guard by auth type
const authType = config.getAuthType();
if (authType !== AuthType.LOGIN_WITH_GOOGLE && authType !== AuthType.COMPUTE_ADC) {
throw new Error(`Code Assist requires OAuth auth, got ${authType}`);
}
const gen = await createCodeAssistContentGenerator(httpOpts, authType, config); Defensive patterns
Strategy: type-guard
Validate before calling
// Check auth type before calling the factory
const authType = config.getAuthType();
if (authType !== AuthType.LOGIN_WITH_GOOGLE && authType !== AuthType.COMPUTE_ADC) {
throw new Error(`Code Assist requires OAuth auth (LOGIN_WITH_GOOGLE or COMPUTE_ADC), got ${authType}`);
}
const gen = await createCodeAssistContentGenerator(httpOptions, authType, config); Type guard
function isCodeAssistAuthType(authType: AuthType): authType is typeof AuthType.LOGIN_WITH_GOOGLE | typeof AuthType.COMPUTE_ADC {
return authType === AuthType.LOGIN_WITH_GOOGLE || authType === AuthType.COMPUTE_ADC;
} Try / catch
try {
gen = await createCodeAssistContentGenerator(httpOptions, authType, config);
} catch (e) {
if (e instanceof Error && e.message.startsWith('Unsupported authType')) {
// Route to the appropriate content generator for the actual auth type
gen = await createAlternativeContentGenerator(authType, config);
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to create auth provider for agent '${this.definition.
- projectId is not defined for CodeAssistServer.
- Invalid Google Cloud Project ID: "${projectId}". The GOOGLE_
- COMPUTE_ADC failed: ${adcMessage}. (LOGIN_WITH_GOOGLE fallba
- ${originalMessage}. The initial COMPUTE_ADC attempt also fai
AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12).
Data as JSON: /api/errors/84a8e99ec437afaa.
Report an issue: GitHub.