From 6b9237f1a1ef28045d36c07eb452e7b76524c19d Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:41:09 +0200 Subject: [PATCH] fix: Images settings cannot be saved without an API key for a feature that is switched off (#32949) On a fresh install the image generation engine is OpenAI with no key, and saving Admin Settings > Images failed with "OpenAI API Key is required." even with Image Generation switched off, which blocked every change on the page, including setting up Image Edit with another engine. Image Edit had the same problem: with Gemini as its engine and no key, the page refused to save even with Image Edit off. Each engine's key or URL is now only asked for while its feature is on, so switching Image Generation or Image Edit on without one is still refused. Fixes #32835 --- .../components/admin/Settings/Images.svelte | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/src/lib/components/admin/Settings/Images.svelte b/src/lib/components/admin/Settings/Images.svelte index 1972105d57..eb0a596fcb 100644 --- a/src/lib/components/admin/Settings/Images.svelte +++ b/src/lib/components/admin/Settings/Images.svelte @@ -108,29 +108,37 @@ }; const updateConfigHandler = async () => { - if ( - config.IMAGE_GENERATION_ENGINE === 'automatic1111' && - config.AUTOMATIC1111_BASE_URL === '' - ) { - toast.error($i18n.t('AUTOMATIC1111 Base URL is required.')); - config.ENABLE_IMAGE_GENERATION = false; + if (config.ENABLE_IMAGE_GENERATION) { + if ( + config.IMAGE_GENERATION_ENGINE === 'automatic1111' && + config.AUTOMATIC1111_BASE_URL === '' + ) { + toast.error($i18n.t('AUTOMATIC1111 Base URL is required.')); + config.ENABLE_IMAGE_GENERATION = false; - return null; - } else if (config.IMAGE_GENERATION_ENGINE === 'comfyui' && config.COMFYUI_BASE_URL === '') { - toast.error($i18n.t('ComfyUI Base URL is required.')); - config.ENABLE_IMAGE_GENERATION = false; + return null; + } else if (config.IMAGE_GENERATION_ENGINE === 'comfyui' && config.COMFYUI_BASE_URL === '') { + toast.error($i18n.t('ComfyUI Base URL is required.')); + config.ENABLE_IMAGE_GENERATION = false; - return null; - } else if (config.IMAGE_GENERATION_ENGINE === 'openai' && config.IMAGES_OPENAI_API_KEY === '') { - toast.error($i18n.t('OpenAI API Key is required.')); - config.ENABLE_IMAGE_GENERATION = false; + return null; + } else if ( + config.IMAGE_GENERATION_ENGINE === 'openai' && + config.IMAGES_OPENAI_API_KEY === '' + ) { + toast.error($i18n.t('OpenAI API Key is required.')); + config.ENABLE_IMAGE_GENERATION = false; - return null; - } else if (config.IMAGE_GENERATION_ENGINE === 'gemini' && config.IMAGES_GEMINI_API_KEY === '') { - toast.error($i18n.t('Gemini API Key is required.')); - config.ENABLE_IMAGE_GENERATION = false; + return null; + } else if ( + config.IMAGE_GENERATION_ENGINE === 'gemini' && + config.IMAGES_GEMINI_API_KEY === '' + ) { + toast.error($i18n.t('Gemini API Key is required.')); + config.ENABLE_IMAGE_GENERATION = false; - return null; + return null; + } } const res = await updateConfig(localStorage.token, { @@ -729,7 +737,7 @@ variant="settings" placeholder={$i18n.t('settings.admin.images.imagesGeminiApiKey.label')} bind:value={config.IMAGES_GEMINI_API_KEY} - required={true} + required={config.ENABLE_IMAGE_GENERATION} /> @@ -1031,7 +1039,7 @@ variant="settings" placeholder={$i18n.t('settings.admin.images.imagesEditGeminiApiKey.label')} bind:value={config.IMAGES_EDIT_GEMINI_API_KEY} - required={true} + required={config.ENABLE_IMAGE_EDIT} />