fix: remove authType fallback option for cold start case

This commit is contained in:
mingholy.lmh 2026-01-08 14:15:07 +08:00
parent 2662639280
commit 85bc0833b4
8 changed files with 70 additions and 46 deletions

View file

@ -20,21 +20,27 @@ export async function validateNonInteractiveAuth(
try {
// Get the actual authType from config which has already resolved CLI args, env vars, and settings
const authType = nonInteractiveConfig.modelsConfig.getCurrentAuthType();
if (!authType) {
throw new Error(
'No auth type is selected. Please configure an auth type (e.g. via settings) before running in non-interactive mode.',
);
}
const resolvedAuthType: NonNullable<typeof authType> = authType;
const enforcedType = settings.merged.security?.auth?.enforcedType;
if (enforcedType && enforcedType !== authType) {
const message = `The configured auth type is ${enforcedType}, but the current auth type is ${authType}. Please re-authenticate with the correct type.`;
if (enforcedType && enforcedType !== resolvedAuthType) {
const message = `The configured auth type is ${enforcedType}, but the current auth type is ${resolvedAuthType}. Please re-authenticate with the correct type.`;
throw new Error(message);
}
if (!useExternalAuth) {
const err = validateAuthMethod(authType, nonInteractiveConfig);
const err = validateAuthMethod(resolvedAuthType, nonInteractiveConfig);
if (err != null) {
throw new Error(err);
}
}
await nonInteractiveConfig.refreshAuth(authType);
await nonInteractiveConfig.refreshAuth(resolvedAuthType);
return nonInteractiveConfig;
} catch (error) {
const outputFormat = nonInteractiveConfig.getOutputFormat();