Fix cloud authentication failure handling to prevent initialization crash

Co-authored-by: ikechan8370 <21212372+ikechan8370@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-12 03:52:52 +00:00
parent 4d41e7e617
commit 720c81dd7f

View file

@ -46,6 +46,7 @@ export async function authCloud (apiKey = ChatGPTConfig.chaite.cloudApiKey) {
return Chaite.getInstance().getToolsManager().cloudService.getUser() return Chaite.getInstance().getToolsManager().cloudService.getUser()
} catch (err) { } catch (err) {
logger.error(err) logger.error(err)
return null
} }
} }
@ -133,7 +134,11 @@ export async function initChaite () {
await migrateDatabase() await migrateDatabase()
if (ChatGPTConfig.chaite.cloudApiKey) { if (ChatGPTConfig.chaite.cloudApiKey) {
const user = await authCloud(ChatGPTConfig.chaite.cloudApiKey) const user = await authCloud(ChatGPTConfig.chaite.cloudApiKey)
logger.info(`Chaite.Cloud 认证成功, 当前用户${user.username || user.email} (${user.user_id})`) if (user) {
logger.info(`Chaite.Cloud 认证成功, 当前用户${user.username || user.email} (${user.user_id})`)
} else {
logger.warn('Chaite.Cloud 认证失败,将继续使用本地功能')
}
} }
await initRagManager(ChatGPTConfig.llm.embeddingModel, ChatGPTConfig.llm.dimensions) await initRagManager(ChatGPTConfig.llm.embeddingModel, ChatGPTConfig.llm.dimensions)
if (!ChatGPTConfig.chaite.authKey) { if (!ChatGPTConfig.chaite.authKey) {