[GH-ISSUE #10000] SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON #15729

Closed
opened 2026-04-19 21:53:03 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @LuyiTian on GitHub (Feb 14, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/10000

Bug Report


I have noticed relevant discussion and issue here.

https://github.com/open-webui/open-webui/issues/9635
https://github.com/open-webui/open-webui/issues/9404
https://github.com/open-webui/open-webui/discussions/9446

I use openresty (ran in docker) to build reverse proxy between my OpenWebUI and a public url. So I increased the timeout and used all the method mentioned in the above page. but non of them works.

I have noticed although these issues all report the SyntaxError. the content of the error is different. for me it is always <!DOCTYPE

Installation Method

Docker

Environment

  • Open WebUI Version: [ v0.5.10]

  • Ollama (if applicable): not usieng Olllama

  • Operating System: [ Ubuntu 24.04 remote server]

  • Browser (if applicable): [Chrome, but the same in other browsers

Confirmation:

  • [x ] I have read and followed all the instructions provided in the README.md.
  • [ x] I am on the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • [ x] I have included the Docker container logs.
  • I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.

Expected Behavior:

[Describe what you expected to happen.]

Actual Behavior:

When use webserach with long context, I sometimes got this error:

SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

Description

Reproduction Details

Steps to Reproduce:
it does not always happen but when I enable web search with long context the chance of error occuring is much higher

Logs and Screenshots

Docker Container Logs:
I opened the broswer and the docker log winder side by side. and interestly, when the error occurs in my chat window, I can see this log appear in the docker logs:

INFO: 2403:4a00:4001:13:115:115:5698:1a2c:0 - "GET /api/v1/chats/?page=1 HTTP/1.1" 200 OK

Screenshots/Screen Recordings (if applicable):

Image

Additional Information

If I wait for a while, it still generate the answer as usual. However I cannot start the next round conversion in the same thread because it will say there are syntax error in previous round

Note

Originally created by @LuyiTian on GitHub (Feb 14, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/10000 # Bug Report --- I have noticed relevant discussion and issue here. https://github.com/open-webui/open-webui/issues/9635 https://github.com/open-webui/open-webui/issues/9404 https://github.com/open-webui/open-webui/discussions/9446 I use openresty (ran in docker) to build reverse proxy between my OpenWebUI and a public url. So I increased the timeout and used all the method mentioned in the above page. but non of them works. I have noticed although these issues all report the `SyntaxError`. the content of the error is different. for me it is always `<!DOCTYPE` ## Installation Method Docker ## Environment - **Open WebUI Version:** [ v0.5.10] - **Ollama (if applicable):** not usieng Olllama - **Operating System:** [ Ubuntu 24.04 remote server] - **Browser (if applicable):** [Chrome, but the same in other browsers **Confirmation:** - [x ] I have read and followed all the instructions provided in the README.md. - [ x] I am on the latest version of both Open WebUI and Ollama. - [ ] I have included the browser console logs. - [ x] I have included the Docker container logs. - [ ] I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below. ## Expected Behavior: [Describe what you expected to happen.] ## Actual Behavior: When use webserach with long context, I sometimes got this error: SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON ## Description ## Reproduction Details **Steps to Reproduce:** it does not always happen but when I enable web search with long context the chance of error occuring is much higher ## Logs and Screenshots **Docker Container Logs:** I opened the broswer and the docker log winder side by side. and interestly, when the error occurs in my chat window, I can see this log appear in the docker logs: INFO: 2403:4a00:4001:13:115:115:5698:1a2c:0 - "GET /api/v1/chats/?page=1 HTTP/1.1" 200 OK **Screenshots/Screen Recordings (if applicable):** ![Image](https://github.com/user-attachments/assets/145edfc1-c451-4a1c-823a-5719937a1551) ## Additional Information If I wait for a while, it still generate the answer as usual. However I cannot start the next round conversion in the same thread because it will say there are syntax error in previous round ## Note
Author
Owner

@silentoplayz commented on GitHub (Feb 14, 2025):

Related - https://github.com/open-webui/open-webui/discussions/10022

<!-- gh-comment-id:2660069438 --> @silentoplayz commented on GitHub (Feb 14, 2025): Related - https://github.com/open-webui/open-webui/discussions/10022
Author
Owner

@sirBdone commented on GitHub (Feb 14, 2025):

Yes, I've been having a problem with this too. I also receive HTML instead of JSON when I hit searxng:8080 or host.docker.internal:8080 from the ollama container to the searxng container (both on traefik-net) which serves my ai page on ssl (working fine). I only want searxng open to localhost system or the ollama container, not the web.

I can get http://localhost:8080 to bring up the Searxng search page and work properly. i can do a search like http://localhost:8080/search?q=dogs&format=json and get a full page of json.
example:

{"query": "dogs", "number_of_results": 0, "results": [{"url": "https://en.wikipedia.org/wiki/Dog", "title": "Dog - Wikipedia", "content": "2 weeks ago - The dog (Canis familiaris or Canis lupus familiaris) is a domesticated descendant of the gray wolf. Also called the domestic dog, it was selectively bred from an extinct population of wolves during the Late Pleistocene by hunter-gatherers. The dog was the first species to be domesticated by ...", "publishedDate": null, "thumbnail": null, "engine": "brave", "template": "default.html", "parsed_url": ["https", "en.wikipedia.org", "/wiki/Dog", "", "", ""], "engines": ["google", "brave"], "positions": [1, 1], "sco

So, if I get ollama webui to "search the web" with websearch.py in the tools, and tell it to mirror its context I give it (which should be json from the search), it shows me http://example.com/search?q=dogs&format=json, 404 error. and then tells me it can't find the answer in the context. On docker Logs, I see it give the paragraph for websearch and webscrape, but then an error about JSON not being found.

2025-02-13 11:54:46 ERROR [open_webui.utils.middleware] Error: No JSON object found in the response
2025-02-13 11:54:46 Traceback (most recent call last):
2025-02-13 11:54:46 File "/app/backend/open_webui/utils/middleware.py", line 261, in chat_completion_tools_handler
2025-02-13 11:54:46 raise Exception("No JSON object found in the response")
2025-02-13 11:54:46 Exception: No JSON object found in the response

So, I go to the ollama-openwebui container and do curl http://searxng:8080/search?q=dogs&format=json and it returns to me the html of the results page, not JSON as above, which is a single string. I've seen this similar issue in Searxng and WebUI's github over the last several versions, because new commits are retroactively breaking its functionality, then it's fixed again or not idk, it's not working for me and I believe I have it set up right. I'd really like to figure this out. Today, is V-day so I'll be very busy later today, but I am very eager to work with someone to help fix this issue.

I would say the problem is searxng because it's returning HTML to ollama when it should be returning JSON, but when I do that in the browser of the computer with localhost, its returning the proper JSON results.

<!-- gh-comment-id:2660199906 --> @sirBdone commented on GitHub (Feb 14, 2025): Yes, I've been having a problem with this too. I also receive HTML instead of JSON when I hit searxng:8080 or host.docker.internal:8080 from the ollama container to the searxng container (both on traefik-net) which serves my ai page on ssl (working fine). I only want searxng open to localhost system or the ollama container, not the web. I can get http://localhost:8080 to bring up the Searxng search page and work properly. i can do a search like http://localhost:8080/search?q=dogs&format=json and get a full page of json. example: > {"query": "dogs", "number_of_results": 0, "results": [{"url": "https://en.wikipedia.org/wiki/Dog", "title": "Dog - Wikipedia", "content": "2 weeks ago - The dog (Canis familiaris or Canis lupus familiaris) is a domesticated descendant of the gray wolf. Also called the domestic dog, it was selectively bred from an extinct population of wolves during the Late Pleistocene by hunter-gatherers. The dog was the first species to be domesticated by ...", "publishedDate": null, "thumbnail": null, "engine": "brave", "template": "default.html", "parsed_url": ["https", "en.wikipedia.org", "/wiki/Dog", "", "", ""], "engines": ["google", "brave"], "positions": [1, 1], "sco So, if I get ollama webui to "search the web" with websearch.py in the tools, and tell it to mirror its context I give it (which should be json from the search), it shows me http://example.com/search?q=dogs&format=json, 404 error. and then tells me it can't find the answer in the context. On docker Logs, I see it give the paragraph for websearch and webscrape, but then an error about JSON not being found. > 2025-02-13 11:54:46 ERROR [open_webui.utils.middleware] Error: No JSON object found in the response > 2025-02-13 11:54:46 Traceback (most recent call last): > 2025-02-13 11:54:46 File "/app/backend/open_webui/utils/middleware.py", line 261, in chat_completion_tools_handler > 2025-02-13 11:54:46 raise Exception("No JSON object found in the response") > 2025-02-13 11:54:46 Exception: No JSON object found in the response So, I go to the ollama-openwebui container and do curl http://searxng:8080/search?q=dogs&format=json and it returns to me the html of the results page, not JSON as above, which is a single string. I've seen this similar issue in Searxng and WebUI's github over the last several versions, because new commits are retroactively breaking its functionality, then it's fixed again or not idk, it's not working for me and I believe I have it set up right. I'd really like to figure this out. Today, is V-day so I'll be very busy later today, but I am very eager to work with someone to help fix this issue. I would say the problem is searxng because it's returning HTML to ollama when it should be returning JSON, but when I do that in the browser of the computer with localhost, its returning the proper JSON results.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#15729