From cc15a01778350f627c925da1efb7bbff259bb7f2 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 1 Jun 2026 19:41:43 +0200 Subject: [PATCH] fix: don't crash on startup when stdout can't encode the banner (#25482) The startup banner uses Unicode box-drawing characters. On a stdout that can't encode them (Windows cp1252, or redirected/headless/pythonw output) print() raises UnicodeEncodeError and aborts startup. This blocks running open-webui serve headless on Windows. Guard the banner print and fall back to a plain ASCII line so startup always proceeds regardless of the console encoding. Fixes #24965 Co-authored-by: Claude Opus 4.8 (1M context) --- backend/open_webui/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 6250dd947e..7dc765a56c 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -608,7 +608,7 @@ class SPAStaticFiles(StaticFiles): if LOG_FORMAT != 'json': - print(rf""" + banner = rf""" ██████╗ ██████╗ ███████╗███╗ ██╗ ██╗ ██╗███████╗██████╗ ██╗ ██╗██╗ ██╔═══██╗██╔══██╗██╔════╝████╗ ██║ ██║ ██║██╔════╝██╔══██╗██║ ██║██║ ██║ ██║██████╔╝█████╗ ██╔██╗ ██║ ██║ █╗ ██║█████╗ ██████╔╝██║ ██║██║ @@ -620,7 +620,12 @@ if LOG_FORMAT != 'json': v{VERSION} - building the best AI user interface. {f'Commit: {WEBUI_BUILD_HASH}' if WEBUI_BUILD_HASH != 'dev-build' else ''} https://github.com/open-webui/open-webui -""") +""" + try: + print(banner) + except UnicodeEncodeError: + # Stdout can't encode the box-drawing banner (Windows cp1252, redirected/headless stdout); fall back to ASCII. + print(f'Open WebUI v{VERSION} - building the best AI user interface.\nhttps://github.com/open-webui/open-webui') @asynccontextmanager