From c9f9c4b1da37684972217b44c79e1cf5c9d07beb Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sat, 10 Oct 2026 17:59:52 +0200 Subject: [PATCH] fix: functions and tools with a required Valves field cannot be saved (#32165) Since the recent change that keeps a history of function and tool edits, saving a new function or tool whose Valves (its admin settings, such as an API key) have a required field with no default was refused with "Current Valves are incompatible with this code: ... Field required", because a new one has no Valves set yet. Editing the code to add a new required field failed the same way. Missing required fields no longer block saving, so the function or tool can be installed first and its Valves filled in afterwards, as before that change. Saved Valves that have the wrong type for the new code are still rejected. Fixes #32145 --- backend/open_webui/utils/valves.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/open_webui/utils/valves.py b/backend/open_webui/utils/valves.py index e21945dd24..eb33cf58b5 100644 --- a/backend/open_webui/utils/valves.py +++ b/backend/open_webui/utils/valves.py @@ -50,6 +50,9 @@ def validate_valves(module, valves): # Validate without replacing the stored values (including unused keys/secrets). module.Valves(**{key: value for key, value in values.items() if value is not None}) except Exception as error: + # Required fields with no stored value yet get filled in after saving. + if isinstance(error, ValidationError) and all(item['type'] == 'missing' for item in error.errors()): + return detail = ( '; '.join( f'{".".join(map(str, item["loc"]))}: {item["msg"]}' for item in error.errors(include_input=False)