[GH-ISSUE #23543] issue: Open WebUI crashes with RecursionError when Tool Server OpenAPI spec contains circular $ref schemas #58675

Closed
opened 2026-05-05 23:41:35 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @stepek on GitHub (Apr 9, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/23543

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!).
  • I am using the latest version of Open WebUI.

Installation Method

Git Clone

Open WebUI Version

0.8.12

Ollama Version (if applicable)

No response

Operating System

ubuntu 22.04

Browser (if applicable)

No response

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

Expected Behavior

When configuring a Tool Server whose OpenAPI specification contains circular $ref references (e.g. a schema that references itself through a nested property), Open WebUI should gracefully handle the recursive schema resolution — either by detecting the cycle and stopping, or by limiting the resolution depth. The /api/v1/tools/ endpoint should return successfully and all configured Tool Servers should remain functional.

Actual Behavior

The resolve_schema function in /app/backend/open_webui/utils/tools.py enters infinite recursion when encountering a self-referencing $ref in the OpenAPI spec. This causes a RecursionError that crashes the entire /api/v1/tools/ endpoint with HTTP 500, making all configured Tool Servers unavailable — not just the one with the circular schema.

Steps to Reproduce

1Set up an external API that exposes an OpenAPI 3.x spec containing a circular $ref, for example a schema like:


json"Condition": {
  "properties": {
    "siblings": {
      "items": {
        "$ref": "#/components/schemas/Condition"
      },
      "type": "array"
    }
  }
}

2In Open WebUI Admin settings, add this API as a Tool Server connection by providing its OpenAPI spec URL.
3Navigate to any page that triggers a call to GET /api/v1/tools/.
4Observe that the request fails with HTTP 500 and the logs show a RecursionError with repeated frames in resolve_schema at lines 707, 714, and 717 of tools.py.
5Note that all other Tool Servers also become inaccessible because the error aborts the entire get_tool_servers_data call.

Logs & Screenshots

2026-04-09 12:00:15.035 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 10.116.4.1:0 - "GET /api/v1/tools/ HTTP/1.1" 500

  • Exception Group Traceback (most recent call last):
    | File "/usr/local/lib/python3.12/site-packages/starlette/_utils.py", line 81, in collapse_excgroups
    | yield
    | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 192, in call
    | async with anyio.create_task_group() as task_group:
    | File "/usr/local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 799, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/app/backend/open_webui/routers/tools.py", line 86, in get_tools
    | for server in await get_tool_servers(request):
    | File "/app/backend/open_webui/utils/tools.py", line 813, in get_tool_servers
    | tool_servers = await set_tool_servers(request)
    | File "/app/backend/open_webui/utils/tools.py", line 795, in set_tool_servers
    | request.app.state.TOOL_SERVERS = await get_tool_servers_data(request.app.state.config.TOOL_SERVER_CONNECTIONS)
    | File "/app/backend/open_webui/utils/tools.py", line 1164, in get_tool_servers_data
    | 'specs': convert_openapi_to_tool_payload(response),
    | File "/app/backend/open_webui/utils/tools.py", line 778, in convert_openapi_to_tool_payload
    | resolved_schema = resolve_schema(json_schema, openapi_spec.get('components', {}))
    | File "/app/backend/open_webui/utils/tools.py", line 707, in resolve_schema
    | return resolve_schema(resolved, components)
    | File "/app/backend/open_webui/utils/tools.py", line 714, in resolve_schema
    | resolved_schema['properties'][prop] = resolve_schema(prop_schema, components)
    | File "/app/backend/open_webui/utils/tools.py", line 717, in resolve_schema
    | resolved_schema['items'] = resolve_schema(resolved_schema['items'], components)
    | File "/app/backend/open_webui/utils/tools.py", line 707, in resolve_schema
    | return resolve_schema(resolved, components)
    | File "/app/backend/open_webui/utils/tools.py", line 714, in resolve_schema
    | resolved_schema['properties'][prop] = resolve_schema(prop_schema, components)
    | File "/app/backend/open_webui/utils/tools.py", line 717, in resolve_schema
    | resolved_schema['items'] = resolve_schema(resolved_schema['items'], components)
    |
    | ... (repeating ~200+ times until RecursionError)

Additional Information

No response

Originally created by @stepek on GitHub (Apr 9, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/23543 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!). - [x] I am using the latest version of Open WebUI. ### Installation Method Git Clone ### Open WebUI Version 0.8.12 ### Ollama Version (if applicable) _No response_ ### Operating System ubuntu 22.04 ### Browser (if applicable) _No response_ ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### Expected Behavior When configuring a Tool Server whose OpenAPI specification contains circular $ref references (e.g. a schema that references itself through a nested property), Open WebUI should gracefully handle the recursive schema resolution — either by detecting the cycle and stopping, or by limiting the resolution depth. The /api/v1/tools/ endpoint should return successfully and all configured Tool Servers should remain functional. ### Actual Behavior The resolve_schema function in /app/backend/open_webui/utils/tools.py enters infinite recursion when encountering a self-referencing $ref in the OpenAPI spec. This causes a RecursionError that crashes the entire /api/v1/tools/ endpoint with HTTP 500, making all configured Tool Servers unavailable — not just the one with the circular schema. ### Steps to Reproduce 1Set up an external API that exposes an OpenAPI 3.x spec containing a circular $ref, for example a schema like: ``` json"Condition": { "properties": { "siblings": { "items": { "$ref": "#/components/schemas/Condition" }, "type": "array" } } } ``` 2In Open WebUI Admin settings, add this API as a Tool Server connection by providing its OpenAPI spec URL. 3Navigate to any page that triggers a call to GET /api/v1/tools/. 4Observe that the request fails with HTTP 500 and the logs show a RecursionError with repeated frames in resolve_schema at lines 707, 714, and 717 of tools.py. 5Note that all other Tool Servers also become inaccessible because the error aborts the entire get_tool_servers_data call. ### Logs & Screenshots 2026-04-09 12:00:15.035 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 10.116.4.1:0 - "GET /api/v1/tools/ HTTP/1.1" 500 + Exception Group Traceback (most recent call last): | File "/usr/local/lib/python3.12/site-packages/starlette/_utils.py", line 81, in collapse_excgroups | yield | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 192, in __call__ | async with anyio.create_task_group() as task_group: | File "/usr/local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 799, in __aexit__ | raise BaseExceptionGroup( | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "/app/backend/open_webui/routers/tools.py", line 86, in get_tools | for server in await get_tool_servers(request): | File "/app/backend/open_webui/utils/tools.py", line 813, in get_tool_servers | tool_servers = await set_tool_servers(request) | File "/app/backend/open_webui/utils/tools.py", line 795, in set_tool_servers | request.app.state.TOOL_SERVERS = await get_tool_servers_data(request.app.state.config.TOOL_SERVER_CONNECTIONS) | File "/app/backend/open_webui/utils/tools.py", line 1164, in get_tool_servers_data | 'specs': convert_openapi_to_tool_payload(response), | File "/app/backend/open_webui/utils/tools.py", line 778, in convert_openapi_to_tool_payload | resolved_schema = resolve_schema(json_schema, openapi_spec.get('components', {})) | File "/app/backend/open_webui/utils/tools.py", line 707, in resolve_schema | return resolve_schema(resolved, components) | File "/app/backend/open_webui/utils/tools.py", line 714, in resolve_schema | resolved_schema['properties'][prop] = resolve_schema(prop_schema, components) | File "/app/backend/open_webui/utils/tools.py", line 717, in resolve_schema | resolved_schema['items'] = resolve_schema(resolved_schema['items'], components) | File "/app/backend/open_webui/utils/tools.py", line 707, in resolve_schema | return resolve_schema(resolved, components) | File "/app/backend/open_webui/utils/tools.py", line 714, in resolve_schema | resolved_schema['properties'][prop] = resolve_schema(prop_schema, components) | File "/app/backend/open_webui/utils/tools.py", line 717, in resolve_schema | resolved_schema['items'] = resolve_schema(resolved_schema['items'], components) | | ... (repeating ~200+ times until RecursionError) ### Additional Information _No response_
GiteaMirror added the bug label 2026-05-05 23:41:35 -05:00
Author
Owner

@tjbck commented on GitHub (Apr 12, 2026):

Should be addressed in dev.

<!-- gh-comment-id:4232784846 --> @tjbck commented on GitHub (Apr 12, 2026): Should be addressed in dev.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#58675