fix(litellm): add error handling in onboarding wizard
The AUTH_CHOICE_CANCELLED error was showing to users during onboarding because the applyAuthChoice call in onboarding.ts wasn't wrapped in error handling. This adds the same try-catch loop pattern used in configure.gateway-auth.ts and agents.commands.add.ts to properly handle the cancellation and re-prompt for auth method selection.
This commit is contained in:
parent
ce8fd694ae
commit
327e82da5d
@ -21,6 +21,7 @@ import { promptRemoteGatewayConfig } from "../commands/onboard-remote.js";
|
|||||||
import { setupSkills } from "../commands/onboard-skills.js";
|
import { setupSkills } from "../commands/onboard-skills.js";
|
||||||
import { setupInternalHooks } from "../commands/onboard-hooks.js";
|
import { setupInternalHooks } from "../commands/onboard-hooks.js";
|
||||||
import type {
|
import type {
|
||||||
|
AuthChoice,
|
||||||
GatewayAuthChoice,
|
GatewayAuthChoice,
|
||||||
OnboardMode,
|
OnboardMode,
|
||||||
OnboardOptions,
|
OnboardOptions,
|
||||||
@ -354,26 +355,43 @@ export async function runOnboardingWizard(
|
|||||||
allowKeychainPrompt: false,
|
allowKeychainPrompt: false,
|
||||||
});
|
});
|
||||||
const authChoiceFromPrompt = opts.authChoice === undefined;
|
const authChoiceFromPrompt = opts.authChoice === undefined;
|
||||||
const authChoice =
|
let authChoice: AuthChoice;
|
||||||
opts.authChoice ??
|
|
||||||
(await promptAuthChoiceGrouped({
|
|
||||||
prompter,
|
|
||||||
store: authStore,
|
|
||||||
includeSkip: true,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const authResult = await applyAuthChoice({
|
// Loop to allow retrying auth choice if user cancels during configuration
|
||||||
authChoice,
|
while (true) {
|
||||||
config: nextConfig,
|
authChoice =
|
||||||
prompter,
|
opts.authChoice ??
|
||||||
runtime,
|
(await promptAuthChoiceGrouped({
|
||||||
setDefaultModel: true,
|
prompter,
|
||||||
opts: {
|
store: authStore,
|
||||||
tokenProvider: opts.tokenProvider,
|
includeSkip: true,
|
||||||
token: opts.authChoice === "apiKey" && opts.token ? opts.token : undefined,
|
}));
|
||||||
},
|
|
||||||
});
|
try {
|
||||||
nextConfig = authResult.config;
|
const authResult = await applyAuthChoice({
|
||||||
|
authChoice,
|
||||||
|
config: nextConfig,
|
||||||
|
prompter,
|
||||||
|
runtime,
|
||||||
|
setDefaultModel: true,
|
||||||
|
opts: {
|
||||||
|
tokenProvider: opts.tokenProvider,
|
||||||
|
token: opts.authChoice === "apiKey" && opts.token ? opts.token : undefined,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
nextConfig = authResult.config;
|
||||||
|
break; // Success - exit the loop
|
||||||
|
} catch (error) {
|
||||||
|
// If user cancelled to go back to auth selection, loop again
|
||||||
|
if (error instanceof Error && error.message === "AUTH_CHOICE_CANCELLED") {
|
||||||
|
// Clear opts.authChoice so we prompt again
|
||||||
|
opts.authChoice = undefined;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Re-throw other errors
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (authChoiceFromPrompt) {
|
if (authChoiceFromPrompt) {
|
||||||
const modelSelection = await promptDefaultModel({
|
const modelSelection = await promptDefaultModel({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user