[GH-ISSUE #24575] bug: 'NoneType' object has no attribute 'startswith' on /api/chat/completions when external client omits parent_id #74946

Closed
opened 2026-05-13 07:48:48 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @Ghosterme-dev on GitHub (May 11, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/24575

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

Docker

Open WebUI Version

v0.9.5

Ollama Version (if applicable)

v0.23.2

Operating System

NVIDIA DGX Spark, DGX OS 7.5.0 (Ubuntu 24.04.4 LTS Noble Numbat, ARM64 / aarch64)

Browser (if applicable)

Not applicable

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

External OpenAI-compatible API clients (e.g. Nextcloud integration_openai app, plain curl) should be able to call /api/chat/completions with a minimal payload (without parent_id) and receive a valid chat response.

Actual Behavior

The request fails with HTTP 400 and the error:

{"detail": "'NoneType' object has no attribute 'startswith'"}

The same custom model works fine when used via the Open WebUI browser interface.

Steps to Reproduce

Environment:

  • Open WebUI v0.9.5 in Docker on NVIDIA DGX Spark (DGX OS 7.5.0, Ubuntu 24.04.4 LTS, ARM64)
  • Custom model created in Open WebUI with base_model_id: qwen3.6:35b (Ollama backend, v0.23.2)
  • External client: Nextcloud integration_openai app, or plain curl
  1. Create a custom model in Open WebUI (Admin → Workspace → Models → Create Model)

Set any name (e.g. nextcloud)
Set Base Model to an Ollama model (e.g. qwen3.6:35b)
Leave description empty

  1. Generate an API key in Open WebUI (User Settings → API Keys)

  2. Call the API from an external client without parent_id:

curl -X POST "http://<openwebui-host>/api/chat/completions" \
  -H "Authorization: Bearer <api-key>" \
  -H "Content-Type: application/json" \
  -d '{"model":"nextcloud","messages":[{"role":"user","content":"Test"}]}'

Expected result: HTTP 200 with chat response
Actual result: HTTP 400 'NoneType' object has no attribute 'startswith'

  1. Verify the same model works in the browser UI → it does (HTTP 200).

  2. Adding "stream": false does NOT fix the issue.

Logs & Screenshots

2026-05-11 12:19:46.237 | ERROR | open_webui.main:process_chat:2013 - Error processing chat payload: 'NoneType' object has no attribute 'startswith'
2026-05-11 12:19:46.237 | INFO  | - "POST /api/chat/completions HTTP/1.1" 400

Root cause identified via source inspection of main.py:

is_new_chat is only set to True when parent_id is explicitly present in the request body and is None:

# main.py ~line 1752
`is_new_chat = 'parent_id' in form_data and form_data['parent_id'] is None and not form_data.get('chat_id')`

External API clients do not include parent_id → is_new_chat = False → metadata['chat_id'] stays None. When any exception occurs, the exception handler at ~line 2017 crashes:

if not metadata['chat_id'].startswith('local:') ...
# → AttributeError: 'NoneType' object has no attribute 'startswith'

This masks the original exception and returns a confusing 400 error to the caller.

Proposed fix:

BEFORE:
is_new_chat = 'parent_id' in form_data and form_data['parent_id'] is None and not form_data.get('chat_id')

AFTER:
is_new_chat = not form_data.get('chat_id')

Additional Information

  • Affects all standard OpenAI-compatible clients (Nextcloud integration_openai, plain curl) that do not send parent_id.
  • The Open WebUI browser UI sends parent_id: null explicitly — that is why it works.
  • The proposed fix has been tested locally and resolves the issue.
  • Related discussion: https://github.com/open-webui/open-webui/discussions/24314

docker-compose.yml (relevant excerpt):

open-webui:
  image: ghcr.io/open-webui/open-webui:latest
  environment:
    - OLLAMA_BASE_URL=http://ollama-gpu:11434
    - WEBUI_AUTH=true
    - VECTOR_DB=qdrant
    - RAG_EMBEDDING_ENGINE=ollama
Originally created by @Ghosterme-dev on GitHub (May 11, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/24575 ### 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 Docker ### Open WebUI Version v0.9.5 ### Ollama Version (if applicable) v0.23.2 ### Operating System NVIDIA DGX Spark, DGX OS 7.5.0 (Ubuntu 24.04.4 LTS Noble Numbat, ARM64 / aarch64) ### Browser (if applicable) Not applicable ### 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 External OpenAI-compatible API clients (e.g. Nextcloud integration_openai app, plain curl) should be able to call /api/chat/completions with a minimal payload (without parent_id) and receive a valid chat response. ### Actual Behavior The request fails with HTTP 400 and the error: `{"detail": "'NoneType' object has no attribute 'startswith'"}` The same custom model works fine when used via the Open WebUI browser interface. ### Steps to Reproduce Environment: - Open WebUI v0.9.5 in Docker on NVIDIA DGX Spark (DGX OS 7.5.0, Ubuntu 24.04.4 LTS, ARM64) - Custom model created in Open WebUI with base_model_id: qwen3.6:35b (Ollama backend, v0.23.2) - External client: Nextcloud integration_openai app, or plain curl 1. Create a custom model in Open WebUI (Admin → Workspace → Models → Create Model) Set any name (e.g. nextcloud) Set Base Model to an Ollama model (e.g. qwen3.6:35b) Leave description empty 2. Generate an API key in Open WebUI (User Settings → API Keys) 3. Call the API from an external client without parent_id: ``` curl -X POST "http://<openwebui-host>/api/chat/completions" \ -H "Authorization: Bearer <api-key>" \ -H "Content-Type: application/json" \ -d '{"model":"nextcloud","messages":[{"role":"user","content":"Test"}]}' ``` Expected result: HTTP 200 with chat response Actual result: HTTP 400 'NoneType' object has no attribute 'startswith' 4. Verify the same model works in the browser UI → it does (HTTP 200). 5. Adding "stream": false does NOT fix the issue. ### Logs & Screenshots ``` 2026-05-11 12:19:46.237 | ERROR | open_webui.main:process_chat:2013 - Error processing chat payload: 'NoneType' object has no attribute 'startswith' 2026-05-11 12:19:46.237 | INFO | - "POST /api/chat/completions HTTP/1.1" 400 ``` Root cause identified via source inspection of main.py: is_new_chat is only set to True when parent_id is explicitly present in the request body and is None: ``` # main.py ~line 1752 `is_new_chat = 'parent_id' in form_data and form_data['parent_id'] is None and not form_data.get('chat_id')` ``` External API clients do not include parent_id → is_new_chat = False → metadata['chat_id'] stays None. When any exception occurs, the exception handler at ~line 2017 crashes: ``` if not metadata['chat_id'].startswith('local:') ... # → AttributeError: 'NoneType' object has no attribute 'startswith' ``` This masks the original exception and returns a confusing 400 error to the caller. Proposed fix: BEFORE: `is_new_chat = 'parent_id' in form_data and form_data['parent_id'] is None and not form_data.get('chat_id')` AFTER: `is_new_chat = not form_data.get('chat_id')` ### Additional Information - Affects all standard OpenAI-compatible clients (Nextcloud integration_openai, plain curl) that do not send parent_id. - The Open WebUI browser UI sends parent_id: null explicitly — that is why it works. - The proposed fix has been tested locally and resolves the issue. - Related discussion: https://github.com/open-webui/open-webui/discussions/24314 docker-compose.yml (relevant excerpt): ``` open-webui: image: ghcr.io/open-webui/open-webui:latest environment: - OLLAMA_BASE_URL=http://ollama-gpu:11434 - WEBUI_AUTH=true - VECTOR_DB=qdrant - RAG_EMBEDDING_ENGINE=ollama ```
GiteaMirror added the bug label 2026-05-13 07:48:48 -05:00
Author
Owner

@owui-terminator[bot] commented on GitHub (May 11, 2026):

🔍 Related Issues Found

I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions:

  1. 🟢 #24553 issue: /api/chat/completions runs into error
    Same endpoint and same 'NoneType' object has no attribute 'startswith' failure on /api/chat/completions in v0.9.5. It appears to be the same API regression, though this report is less specific about the missing parent_id condition.
    by tweinberger-lei · bug

  2. 🟣 #24564 bug: API calls to /api/chat/completions fail: "'NoneType' object has no attribute 'startswith'"
    Direct match on the same error, endpoint, version range, and API-only failure. It reports /api/chat/completions returning HTTP 400 with the exact startswith exception, making it highly related.
    by da-astro · bug

  3. 🟣 #24573 issue: External API returns 400 error with 'NoneType' object has no attribute 'startswith' since v0.9.3**
    Same error and same external API symptom since v0.9.3, with a curl repro against /api/chat/completions. This is closely related to the new issue’s external-client context and version regression.
    by choseongho11 · bug


💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead.

This comment was generated automatically. React with 👍 if helpful, 👎 if not.

<!-- gh-comment-id:4420417179 --> @owui-terminator[bot] commented on GitHub (May 11, 2026): <!-- terminator-bot:related-issues-reply --> 🔍 **Related Issues Found** I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions: 1. 🟢 [#24553](https://github.com/open-webui/open-webui/issues/24553) **issue: /api/chat/completions runs into error** *Same endpoint and same `'NoneType' object has no attribute 'startswith'` failure on `/api/chat/completions` in v0.9.5. It appears to be the same API regression, though this report is less specific about the missing `parent_id` condition.* *by tweinberger-lei · `bug`* 2. 🟣 [#24564](https://github.com/open-webui/open-webui/issues/24564) **bug: API calls to /api/chat/completions fail: "'NoneType' object has no attribute 'startswith'"** *Direct match on the same error, endpoint, version range, and API-only failure. It reports `/api/chat/completions` returning HTTP 400 with the exact `startswith` exception, making it highly related.* *by da-astro · `bug`* 3. 🟣 [#24573](https://github.com/open-webui/open-webui/issues/24573) **issue: External API returns 400 error with 'NoneType' object has no attribute 'startswith' since v0.9.3**** *Same error and same external API symptom since v0.9.3, with a curl repro against `/api/chat/completions`. This is closely related to the new issue’s external-client context and version regression.* *by choseongho11 · `bug`* --- 💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead. *This comment was generated automatically.* React with 👍 if helpful, 👎 if not.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#74946