[PR #22115] [CLOSED] fix(tools): normalize tool server URLs to prevent double-slash issues #49546

Closed
opened 2026-04-30 01:50:42 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22115
Author: @eren-karakus0
Created: 3/1/2026
Status: Closed

Base: devHead: fix/tool-server-url-path


📝 Commits (1)

  • d71e329 fix(tools): normalize tool server URLs to prevent double-slash issues

📊 Changes

2 files changed (+75 additions, -2 deletions)

View changed files

backend/open_webui/test/util/test_tools.py (+71 -0)
📝 backend/open_webui/utils/tools.py (+4 -2)

📄 Description

Pull Request Checklist

  • Target branch: Verify that the pull request targets the dev branch.
  • Description: Provided below.
  • Changelog: Provided below.
  • Testing: 12 unit tests added; manual ad-hoc verification of all URL normalization scenarios.
  • Code review: Self-reviewed; Black formatter applied.
  • Git Hygiene: Atomic PR (single logical change), rebased on dev.
  • Title Prefix: fix:

Changelog Entry

Description

Fixes #21917

When a tool server URL includes a trailing slash (e.g. http://host:8080/v1/), joining it with a path like /openapi.json or a route like /search produces a double-slash URL (http://host:8080/v1//openapi.json). Some servers reject or misroute these malformed URLs, causing connection failures.

Fixed

  • Strip trailing slashes from base URLs before path concatenation in three places:
    • get_tool_server_url - spec URL construction (verify flow)
    • get_tool_servers_data - stored URL normalization
    • execute_tool_server - execution URL construction
  • Add None guard on stored URL to prevent AttributeError on malformed configs

Added

  • 12 unit tests for get_tool_server_url covering trailing slashes, subpaths, proxy prefixes, and edge cases (backend/open_webui/test/util/test_tools.py)

Additional Information

  • Only backend/open_webui/utils/tools.py modified (4 additions, 2 deletions)
  • No new dependencies
  • No breaking changes - existing URLs without trailing slashes behave identically

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22115 **Author:** [@eren-karakus0](https://github.com/eren-karakus0) **Created:** 3/1/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/tool-server-url-path` --- ### 📝 Commits (1) - [`d71e329`](https://github.com/open-webui/open-webui/commit/d71e3290869d1fbae9dfb074785f0d17f5deef55) fix(tools): normalize tool server URLs to prevent double-slash issues ### 📊 Changes **2 files changed** (+75 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `backend/open_webui/test/util/test_tools.py` (+71 -0) 📝 `backend/open_webui/utils/tools.py` (+4 -2) </details> ### 📄 Description <!-- ⚠️ CRITICAL CHECKS FOR CONTRIBUTORS (READ, DON'T DELETE) ⚠️ 1. Target the `dev` branch. PRs targeting `main` will be automatically closed. 2. Do NOT delete the CLA section at the bottom. It is required for the bot to accept your PR. --> # Pull Request Checklist - [x] **Target branch:** Verify that the pull request targets the `dev` branch. - [x] **Description:** Provided below. - [x] **Changelog:** Provided below. - [x] **Testing:** 12 unit tests added; manual ad-hoc verification of all URL normalization scenarios. - [x] **Code review:** Self-reviewed; Black formatter applied. - [x] **Git Hygiene:** Atomic PR (single logical change), rebased on `dev`. - [x] **Title Prefix:** `fix:` # Changelog Entry ### Description Fixes #21917 When a tool server URL includes a trailing slash (e.g. `http://host:8080/v1/`), joining it with a path like `/openapi.json` or a route like `/search` produces a double-slash URL (`http://host:8080/v1//openapi.json`). Some servers reject or misroute these malformed URLs, causing connection failures. ### Fixed - Strip trailing slashes from base URLs before path concatenation in three places: - `get_tool_server_url` - spec URL construction (verify flow) - `get_tool_servers_data` - stored URL normalization - `execute_tool_server` - execution URL construction - Add `None` guard on stored URL to prevent `AttributeError` on malformed configs ### Added - 12 unit tests for `get_tool_server_url` covering trailing slashes, subpaths, proxy prefixes, and edge cases (`backend/open_webui/test/util/test_tools.py`) --- ### Additional Information - Only `backend/open_webui/utils/tools.py` modified (4 additions, 2 deletions) - No new dependencies - No breaking changes - existing URLs without trailing slashes behave identically ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-30 01:50:42 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#49546