mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #16812] [CLOSED] Fix - Restore Claude Code Router compatibility ('list' object has no attribute 'replace') #63103
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/16812
Author: @igorhvr
Created: 8/22/2025
Status: ❌ Closed
Base:
dev← Head:dev📝 Commits (1)
2916782Fix - Restore Claude Code Router compatibility ('list' object has no attribute 'replace')📊 Changes
4 files changed (+93 additions, -2 deletions)
View changed files
📝
backend/open_webui/main.py(+8 -0)📝
backend/open_webui/routers/ollama.py(+14 -1)📝
backend/open_webui/routers/openai.py(+13 -1)📝
backend/open_webui/utils/payload.py(+58 -0)📄 Description
Background / Problem:
Since Open WebUI v0.6.23, the OpenAI-compatible chat endpoints began assuming message.content and system are strings during preprocessing.
Claude Code Router (CCR) (and other Anthropic-style clients) legitimately send arrays of parts for messages[i].content (and sometimes system), e.g.:
{"role":"user","content":[{"type":"text","text":"Say OK"}]}
Open Web UI v0.6.22 tolerated this; v0.6.23 crashes with:
{"detail":"'list' object has no attribute 'replace'"}
because string ops (e.g., .replace, .strip) are applied to a list.
Goal: Make /api/chat/completions and /api/v1/chat/completions robust to string or array content for:
This is achieved by normalizing chat payload content.
Open web ui v0.6.23 example (the regression which breaks claude code router usage):
igorhvr:open-webui/ $ curl -s -X POST http://localhost:8000/api/v1/chat/completions
-H "Authorization: Bearer sk-ELIDED" -H "Content-Type: application/json"
-d '{"model":"ollama.gemma3:27b","messages":[
{"role":"system","content":[{"type":"text","text":"You are helpful."}]},
{"role":"user","content":[{"type":"text","text":"Say OK"}]}
]}'
{"detail":"'list' object has no attribute 'replace'"}%
Open web ui v0.6.22 example:
igorhvr:open-webui/ $ curl -s -X POST http://localhost:3000/api/v1/chat/completions
-H "Authorization: Bearer sk-ELIDED" -H "Content-Type: application/json"
-d '{"model":"ollama.gemma3:27b","messages":[
{"role":"system","content":[{"type":"text","text":"You are helpful."}]},
{"role":"user","content":[{"type":"text","text":"Say OK"}]}
]}'
{"id":"gemma3:27b-3809e0c6-bbc5-4666-b75a-342b04209700","created":1755855779,"model":"gemma3:27b","choices":[{"index":0,"logprobs":null,"finish_reason":"stop","message":{"role":"assistant","content":"OK.\n\n\n\nIs there anything I can help you with? 😊\n\n\n\n"}}],"object":"chat.completion","usage":{"response_token/s":2.43,"prompt_token/s":6.36,"total_duration":14312802695,"load_duration":4936762602,"prompt_eval_count":20,"prompt_tokens":20,"prompt_eval_duration":3143677971,"eval_count":15,"completion_tokens":15,"eval_duration":6171468695,"approximate_total":"0h0m14s","total_tokens":35,"completion_tokens_details":{"reasoning_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}}%
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Re: I tried to document the exact details in the pull request. Please let me know if this still necessary.
Before submitting, make sure you've checked the following:
Target branch: Please verify that the pull request targets the
devbranch.Description: Provide a concise description of the changes made in this pull request.
Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
Testing: Have you written and run sufficient tests to validate the changes?
This was NOT yet tested.
Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
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.