From 32079981145124143452727b9c0f156e5b394b34 Mon Sep 17 00:00:00 2001 From: xqqp <107686855+xqqp@users.noreply.github.com> Date: Thu, 13 Nov 2025 04:57:53 +0100 Subject: [PATCH] Fix: Handle empty strings in OAuth registration response (#19144) - The mcp package requires optional unset values to be None. If an empty string is passed, it gets validated and fails. - Replace all empty strings with None. --- backend/open_webui/utils/oauth.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/open_webui/utils/oauth.py b/backend/open_webui/utils/oauth.py index 392f4cd4b..039e7cd4c 100644 --- a/backend/open_webui/utils/oauth.py +++ b/backend/open_webui/utils/oauth.py @@ -330,6 +330,10 @@ async def get_oauth_client_info_with_dynamic_client_registration( registration_response_json = ( await oauth_client_registration_response.json() ) + + # The mcp package requires optional unset values to be None. If an empty string is passed, it gets validated and fails. + # This replaces all empty strings with None. + registration_response_json = {k: (None if v == "" else v) for k, v in registration_response_json.items()} oauth_client_info = OAuthClientInformationFull.model_validate( { **registration_response_json,