From 395470eb38947ebf388479436140d8ef495f00bb Mon Sep 17 00:00:00 2001 From: ju6ge Date: Mon, 30 Mar 2026 14:38:38 +0200 Subject: [PATCH] add logic to skip keys in `path_item` objects that aren't methods! --- backend/open_webui/utils/tools.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index 377a81d749..c25b908373 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -738,6 +738,21 @@ def convert_openapi_to_tool_payload(openapi_spec): for path, methods in openapi_spec.get('paths', {}).items(): for method, operation in methods.items(): + + non_method_path_item_keys = ['$ref', 'summary', 'description', 'servers', 'parameters'] + if method in non_method_path_item_keys: + # not every key in the path item type represents a method! + # https://swagger.io/specification/#path-item-object + # + # - `$ref` TODO figure out how to handle $ref, this could be interesting because the definition + # of this path is defined at a different place in the specification + # - `summary` can be ignored safely + # - `description` can be ignored safely + # - `servers`: Probably ignore, it seems pretty exoctic to have specific endpoints for very specific requests + # - `parameters`: might be important to handle at some point because it introduces common parameters for all methods + # probalby rarely used in the wild + continue + if operation.get('operationId'): tool = { 'name': operation.get('operationId'), @@ -1229,6 +1244,19 @@ async def execute_tool_server( method_entry = None for http_method, operation in methods.items(): + non_method_path_item_keys = ['$ref', 'summary', 'description', 'servers', 'parameters'] + if http_method in non_method_path_item_keys: + # not every key in the path item type represents a method! + # https://swagger.io/specification/#path-item-object + # + # - `$ref` TODO figure out how to handle $ref, this could be interesting because the definition + # of this path is defined at a different place in the specification + # - `summary` can be ignored safely + # - `description` can be ignored safely + # - `servers`: Probably ignore, it seems pretty exoctic to have specific endpoints for very specific requests + # - `parameters`: might be important to handle at some point because it introduces common parameters for all methods + # probalby rarely used in the wild + continue if operation.get('operationId') == name: method_entry = (http_method.lower(), operation) break