From ce9c8fe1cfce850e95a5637fe8faa605a799639b Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 8 Oct 2025 20:59:36 +0700 Subject: [PATCH] Update web-app/src/lib/completion.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- web-app/src/lib/completion.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web-app/src/lib/completion.ts b/web-app/src/lib/completion.ts index 68cc7183c..3834cb68f 100644 --- a/web-app/src/lib/completion.ts +++ b/web-app/src/lib/completion.ts @@ -187,9 +187,10 @@ export const sendCompletion = async ( if (!secretKey) { throw new Error('Encryption key unavailable: cannot decrypt API key.') } - const apiKey = provider.api_key - ? decryptApiKey(provider.api_key, secretKey) - : (secretKey ?? '') + if (!provider.api_key) { + throw new Error('API key is missing for the selected provider.'); + } + const apiKey = decryptApiKey(provider.api_key, secretKey); const tokenJS = new TokenJS({ apiKey,