From d0b80d75900385a54e0f8ca8b90f276909e86560 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 26 Nov 2025 15:39:26 -0600 Subject: [PATCH] show config error message when starting in safe mode --- web/src/pages/ConfigEditor.tsx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/web/src/pages/ConfigEditor.tsx b/web/src/pages/ConfigEditor.tsx index 364c13252..f3c4d4099 100644 --- a/web/src/pages/ConfigEditor.tsx +++ b/web/src/pages/ConfigEditor.tsx @@ -49,6 +49,7 @@ function ConfigEditor() { const [restartDialogOpen, setRestartDialogOpen] = useState(false); const { send: sendRestart } = useRestart(); + const initialValidationRef = useRef(false); const onHandleSaveConfig = useCallback( async (save_option: SaveOptions): Promise => { @@ -171,6 +172,33 @@ function ConfigEditor() { }; }, [rawConfig, apiHost, systemTheme, theme, onHandleSaveConfig]); + // when in safe mode, attempt to validate the existing (invalid) config immediately + // so that the user sees the validation errors without needing to press save + useEffect(() => { + if ( + config?.safe_mode && + rawConfig && + !initialValidationRef.current && + !error + ) { + initialValidationRef.current = true; + axios + .post(`config/save?save_option=saveonly`, rawConfig, { + headers: { "Content-Type": "text/plain" }, + }) + .then(() => { + // if this succeeds while in safe mode, we won't force any UI change + }) + .catch((e: AxiosError) => { + const errorMessage = + e.response?.data?.message || + e.response?.data?.detail || + "Unknown error"; + setError(errorMessage); + }); + } + }, [config?.safe_mode, rawConfig, error]); + // monitoring state const [hasChanges, setHasChanges] = useState(false);