Open WebUI errors when Ollama server version isn't an integer (e.g. SHA builds, RCs etc...) #744

Closed
opened 2025-11-11 14:30:16 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @sammcj on GitHub (Apr 27, 2024).

Bug Report

Description

Bug Summary:

If you're building Ollama yourself, by default it doesn't generate a version the same as the release versions, it either generates its version as 0.0.0, as the SHA of the branch/tag you're on (e.g. a2d24d5) or a pre-release RC version (e.g. v0.1.33-RC5).

This seems to cause Open WebUI to experience a crash when checking the Ollama server.

For example, my Ollama build is:

$ curl https://ollama.internal/api/version
{"version":"v0.1.33-rc5"}

Which causes an error in Open WebUI when checking the server:

image

Logs:

...
  File "/app/backend/apps/ollama/main.py", line 219, in <lambda>
    key=lambda x: tuple(map(int, x["version"].split("-")[0].split("."))),
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'v0'

Steps to Reproduce:

Expected Behaviour:

  • Open WebUI to function normally regardless of being on a build with version v1.2.3/v1.2.4-rc5/, (perhaps show a warning in the connection settings if it's an unknown version).

Actual Behaviour:

  • "Server connection failed" in the UI.... but it actually works
  • Errors in the container logs about the version

Environment

  • Open WebUI Version: v0.1.121

  • Ollama (if applicable): v0.1.33-rc5

  • Operating System: Linux/Container

  • Browser (if applicable): Firefox 125

Reproduction Details

Confirmation:

  • I have read and followed all the instructions provided in the README.md.
  • I am on the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.

Logs and Screenshots

Browser Console Logs:
[Include relevant browser console logs, if applicable]

Docker Container Logs:

  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 191, in __call__
    response = await self.dispatch_func(request, call_next)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/backend/apps/ollama/main.py", line 80, in check_url
    response = await call_next(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 165, in call_next
    raise app_exc
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 151, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 758, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 778, in app
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 299, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 79, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 74, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 299, in app
    raise e
  File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 294, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/backend/apps/ollama/main.py", line 217, in get_ollama_versions
    lowest_version = min(
  File "/app/backend/apps/ollama/main.py", line 219, in <lambda>
    key=lambda x: tuple(map(int, x["version"].split("-")[0].split("."))),
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'v0'
                     ^^^^

Screenshots (if applicable):

As above

Installation Method

Docker

Additional Information

Feel free to ask for any additional info, happy to help

This was the cause of https://github.com/open-webui/open-webui/issues/1591 / https://github.com/open-webui/open-webui/discussions/1592

Originally created by @sammcj on GitHub (Apr 27, 2024). # Bug Report ## Description **Bug Summary:** If you're building Ollama yourself, by default it doesn't generate a version the same as the release versions, it either generates its version as 0.0.0, as the SHA of the branch/tag you're on (e.g. `a2d24d5`) or a pre-release RC version (e.g. `v0.1.33-RC5`). This seems to cause Open WebUI to experience a crash when checking the Ollama server. For example, my Ollama build is: ``` $ curl https://ollama.internal/api/version {"version":"v0.1.33-rc5"} ``` Which causes an error in Open WebUI when checking the server: <img width="445" alt="image" src="https://github.com/open-webui/open-webui/assets/862951/c8cad7c8-a561-4bd1-a6ff-715a46214222"> Logs: ``` ... File "/app/backend/apps/ollama/main.py", line 219, in <lambda> key=lambda x: tuple(map(int, x["version"].split("-")[0].split("."))), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'v0' ``` **Steps to Reproduce:** - Build Ollama from main / a tag etc.... - Note it's version to ensure it's a RC or sha number (curl https://ollama.whatever/api/version) - Connect open-webui to it **Expected Behaviour:** - Open WebUI to function normally regardless of being on a build with version v1.2.3/v1.2.4-rc5/<sha>, (perhaps show a warning in the connection settings if it's an unknown version). **Actual Behaviour:** - "Server connection failed" in the UI.... but it actually works - Errors in the container logs about the version ## Environment - **Open WebUI Version:** v0.1.121 - **Ollama (if applicable):** v0.1.33-rc5 - **Operating System:** Linux/Container - **Browser (if applicable):** Firefox 125 ## Reproduction Details **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. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. ## Logs and Screenshots **Browser Console Logs:** [Include relevant browser console logs, if applicable] **Docker Container Logs:** ``` File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 191, in __call__ response = await self.dispatch_func(request, call_next) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/apps/ollama/main.py", line 80, in check_url response = await call_next(request) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 165, in call_next raise app_exc File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 151, in coro await self.app(scope, receive_or_disconnect, send_no_error) File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 83, in __call__ await self.app(scope, receive, send) File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 758, in __call__ await self.middleware_stack(scope, receive, send) File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 778, in app await route.handle(scope, receive, send) File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 299, in handle await self.app(scope, receive, send) File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 79, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 74, in app response = await func(request) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 299, in app raise e File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 294, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function return await dependant.call(**values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/apps/ollama/main.py", line 217, in get_ollama_versions lowest_version = min( File "/app/backend/apps/ollama/main.py", line 219, in <lambda> key=lambda x: tuple(map(int, x["version"].split("-")[0].split("."))), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'v0' ^^^^ ``` **Screenshots (if applicable):** As above ## Installation Method Docker ## Additional Information Feel free to ask for any additional info, happy to help This was the cause of https://github.com/open-webui/open-webui/issues/1591 / https://github.com/open-webui/open-webui/discussions/1592
Author
Owner

@tjbck commented on GitHub (Apr 27, 2024):

Thanks for letting us know! Should be fixed on our dev branch, let me know if the issue persists!

@tjbck commented on GitHub (Apr 27, 2024): Thanks for letting us know! Should be fixed on our dev branch, let me know if the issue persists!
Author
Owner

@sammcj commented on GitHub (Apr 28, 2024):

Confirmed fixed, thank you!

@sammcj commented on GitHub (Apr 28, 2024): Confirmed fixed, thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#744