fix(cliproxy): improve multi-provider auth with continue-on-error pattern

- Continue to remaining providers on auth failure instead of throwing
- Aggregate failures and show summary of succeeded/failed providers
- Improves UX when one provider fails in composite variant
This commit is contained in:
Tam Nhu Tran
2026-02-12 11:01:27 +07:00
parent 0c7dc398f7
commit 6ff17d8480
+10 -2
View File
@@ -497,6 +497,7 @@ export async function execClaudeWithCLIProxy(
// Handle forceAuth for composite providers
if (forceAuth) {
const { triggerOAuth } = await import('../auth-handler');
const failures: string[] = [];
for (const p of compositeProviders) {
const authSuccess = await triggerOAuth(p, {
verbose,
@@ -508,10 +509,17 @@ export async function execClaudeWithCLIProxy(
...(portForward ? { portForward: true } : {}),
});
if (!authSuccess) {
const pConfig = getProviderConfig(p as CLIProxyProvider);
throw new Error(`Authentication failed for ${pConfig.displayName}`);
failures.push(p);
}
}
if (failures.length > 0) {
const succeeded = compositeProviders.filter((p) => !failures.includes(p));
console.error(fail(`Auth failed for: ${failures.join(', ')}`));
if (succeeded.length > 0) {
console.error(info(`Succeeded: ${succeeded.join(', ')}`));
}
process.exit(1);
}
process.exit(0);
}