From 0bd295b10bb36b6546fe3bb8af31458bcec1cc2c Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Wed, 31 Dec 2025 14:40:56 +0100 Subject: [PATCH] fix: prevent getOpenAIUrls and getOpenAIKeys crash on null response (#20272) Use optional chaining and nullish coalescing when accessing res.OPENAI_API_BASE_URLS and res.OPENAI_API_KEYS. Returns empty array instead of crashing with 'Cannot read property of null'. --- src/lib/apis/openai/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/apis/openai/index.ts b/src/lib/apis/openai/index.ts index 276fad145..8cf7438ad 100644 --- a/src/lib/apis/openai/index.ts +++ b/src/lib/apis/openai/index.ts @@ -103,7 +103,7 @@ export const getOpenAIUrls = async (token: string = '') => { throw error; } - return res.OPENAI_API_BASE_URLS; + return res?.OPENAI_API_BASE_URLS ?? []; }; export const updateOpenAIUrls = async (token: string = '', urls: string[]) => { @@ -170,7 +170,7 @@ export const getOpenAIKeys = async (token: string = '') => { throw error; } - return res.OPENAI_API_KEYS; + return res?.OPENAI_API_KEYS ?? []; }; export const updateOpenAIKeys = async (token: string = '', keys: string[]) => {