issue: trailing slash in OPENAI_API url isn't handled safely #6146

Closed
opened 2025-11-11 16:46:07 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @theigel on GitHub (Aug 20, 2025).

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Docker

Open WebUI Version

0.6.22

Ollama Version (if applicable)

Operating System

Ubuntu something

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

If I set up my configuration

OPENAI_API_BASE_URL: "https://api.studio.nebius.com/v1/"
OPENAI_API_KEY: "my_key"
MODEL_FILTER_LIST: '["openai/gpt-oss-120b"]'
DEFAULT_MODELS: "openai/gpt-oss-120b"

I expect everything to work (model being detected and used), but instead I get empty list of models and nothing works.

The problem is with trailing slash in "https://api.studio.nebius.com/v1/". If removed, everything works.

I would expect https://github.com/open-webui/open-webui/blob/main/backend/open_webui/routers/openai.py#L506 to be something like

async with session.get(
                        urllib.parse.urljoin(url, "models"),
                        headers=headers,

instead of

async with session.get(
                        f"{url}/models",
                        headers=headers,

Of course, the API provider (Nebius) could also remove extra slashes and process this situation successfully, but anyway.

I assume there may be other similar places in the code. I would suggest using proper URL handling everywhere.

Actual Behavior

No available models detected. Besides, not much useful information in the logs:

Steps to Reproduce

Install a new installation with such a config. No models detected; besides, no clear explanation in the logs.

Logs & Screenshots

2025-08-20 10:32:05.882 | DEBUG    | aiocache.base:get:201 - GET open_webui.routers.openaiget_all_models(<starlette.requests.Request object at 0x7f8054b2ee90>,)[('user', UserModel(id='9a846b07-6005-471c-bd31-c67a4b460756', name='theigel', email='xxxx', role='admin', profile_image_url='data:image/smth', last_active_at=1755685925, updated_at=1755683545, created_at=1755683545, api_key=None, settings=UserSettings(ui={'version': '0.6.22'}), info=None, oauth_sub=None))] False (0.0000)s
2025-08-20 10:32:05.882 | INFO     | open_webui.routers.openai:get_all_models:397 - get_all_models()
2025-08-20 10:32:05.950 | DEBUG    | open_webui.routers.openai:get_all_models_responses:378 - get_all_models:responses() [{'detail': 'Not Found'}]
2025-08-20 10:32:05.950 | DEBUG    | open_webui.routers.openai:merge_models_lists:412 - merge_models_lists <map object at 0x7f80549b6800>
2025-08-20 10:32:05.950 | DEBUG    | open_webui.routers.openai:get_all_models:451 - models: {'data': []}
2025-08-20 10:32:05.950 | DEBUG    | aiocache.base:set:280 - SET open_webui.routers.openaiget_all_models(<starlette.requests.Request object at 0x7f8054b2ee90>,)[('user', UserModel(id='9a846b07-6005-471c-bd31-c67a4b460756', name='theigel', email=xxxxxx, role='admin', profile_image_url='data:image/smth', last_active_at=1755685925, updated_at=1755683545, created_at=1755683545, api_key=None, settings=UserSettings(ui={'version': '0.6.22'}), info=None, oauth_sub=None))] 1 (0.0000)s
2025-08-20 10:32:05.951 | DEBUG    | open_webui.main:get_models:1327 - /api/models returned filtered models accessible to the user: []```

It would be great to see the requested URL in the logs, not just "Not found". And not with DEBUG, but WARN level.

### Additional Information

_No response_
Originally created by @theigel on GitHub (Aug 20, 2025). ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Docker ### Open WebUI Version 0.6.22 ### Ollama Version (if applicable) - ### Operating System Ubuntu something ### 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 If I set up my configuration ``` OPENAI_API_BASE_URL: "https://api.studio.nebius.com/v1/" OPENAI_API_KEY: "my_key" MODEL_FILTER_LIST: '["openai/gpt-oss-120b"]' DEFAULT_MODELS: "openai/gpt-oss-120b" ``` I expect everything to work (model being detected and used), but instead I get empty list of models and nothing works. The problem is with trailing slash in `"https://api.studio.nebius.com/v1/"`. If removed, everything works. I would expect https://github.com/open-webui/open-webui/blob/main/backend/open_webui/routers/openai.py#L506 to be something like ``` async with session.get( urllib.parse.urljoin(url, "models"), headers=headers, ``` instead of ``` async with session.get( f"{url}/models", headers=headers, ``` Of course, the API provider (Nebius) could also remove extra slashes and process this situation successfully, but anyway. I assume there may be other similar places in the code. I would suggest using proper URL handling everywhere. ### Actual Behavior No available models detected. Besides, not much useful information in the logs: ### Steps to Reproduce Install a new installation with such a config. No models detected; besides, no clear explanation in the logs. ### Logs & Screenshots ``` 2025-08-20 10:32:05.882 | DEBUG | aiocache.base:get:201 - GET open_webui.routers.openaiget_all_models(<starlette.requests.Request object at 0x7f8054b2ee90>,)[('user', UserModel(id='9a846b07-6005-471c-bd31-c67a4b460756', name='theigel', email='xxxx', role='admin', profile_image_url='data:image/smth', last_active_at=1755685925, updated_at=1755683545, created_at=1755683545, api_key=None, settings=UserSettings(ui={'version': '0.6.22'}), info=None, oauth_sub=None))] False (0.0000)s 2025-08-20 10:32:05.882 | INFO | open_webui.routers.openai:get_all_models:397 - get_all_models() 2025-08-20 10:32:05.950 | DEBUG | open_webui.routers.openai:get_all_models_responses:378 - get_all_models:responses() [{'detail': 'Not Found'}] 2025-08-20 10:32:05.950 | DEBUG | open_webui.routers.openai:merge_models_lists:412 - merge_models_lists <map object at 0x7f80549b6800> 2025-08-20 10:32:05.950 | DEBUG | open_webui.routers.openai:get_all_models:451 - models: {'data': []} 2025-08-20 10:32:05.950 | DEBUG | aiocache.base:set:280 - SET open_webui.routers.openaiget_all_models(<starlette.requests.Request object at 0x7f8054b2ee90>,)[('user', UserModel(id='9a846b07-6005-471c-bd31-c67a4b460756', name='theigel', email=xxxxxx, role='admin', profile_image_url='data:image/smth', last_active_at=1755685925, updated_at=1755683545, created_at=1755683545, api_key=None, settings=UserSettings(ui={'version': '0.6.22'}), info=None, oauth_sub=None))] 1 (0.0000)s 2025-08-20 10:32:05.951 | DEBUG | open_webui.main:get_models:1327 - /api/models returned filtered models accessible to the user: []``` It would be great to see the requested URL in the logs, not just "Not found". And not with DEBUG, but WARN level. ### Additional Information _No response_
GiteaMirror added the bug label 2025-11-11 16:46:07 -06:00
Author
Owner

@tjbck commented on GitHub (Aug 21, 2025):

cd762db9bf

@tjbck commented on GitHub (Aug 21, 2025): cd762db9bfe4b42927ee2fcc44b7d878ee5e1c6e
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#6146