Incorrect validation for 'format' field while calling the '/ollama/api/generate' endpoint #4973

Closed
opened 2025-11-11 16:08:31 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @Umutayb on GitHub (Apr 27, 2025).

Check Existing Issues

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

Installation Method

Git Clone

Open WebUI Version

v0.6.5 (latest)

Ollama Version (if applicable)

0.6.5

Operating System

Ubuntu 24.04

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 listed steps to reproduce the bug in detail.

Expected Behavior

Open WebUI docker log:
2025-04-27 14:30:20.351 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 77.169.138.20:49823 - "POST /ollama/api/generate HTTP/1.1" 422 - {}

Ollama docker log:
-- (request does not make it to ollama)

While using open webui as proxy to ollama, create a json schema to 'format' field.
This typically ensures response is in the specified format. But in this case, open webui api reject the request returning 422.

If the same request is sent directly to ollama (which is at a different port), it's successful. Funny enough, if I convert the schema to string, open webui stops complaining but ollama throws a 500 response (invalid schema).

I believe there must be an incorrect validation for the /ollama/api/generate endpoint for the schema field. schema does not have to be a string.

The request body is:
{
"model" : "gemma3:27b",
"prompt" : "Generic prompt",
"stream" : false,
"images" : ["hidden" ],
"options" : {
"temperature" : 1.0,
"seed" : 0
},
"format" : {
"type" : "object",
"properties" : {
"pageExplanation" : {
"type" : "string"
},
"taskComplete" : {
"type" : "boolean"
},
"reason" : {
"type" : "string"
}
},
"required" : [ "expl", "taskComplete", "reason" ]
}
}

The error body is:
{
"detail" : [ {
"type" : "string_type",
"loc" : [ "body", "format" ],
"msg" : "Input should be a valid string",
"input" : {
"type" : "object",
"properties" : {
"pageExplanation" : {
"type" : "string"
},
"taskComplete" : {
"type" : "boolean"
},
"reason" : {
"type" : "string"
}
},
"required" : [ "pageExplanation", "taskComplete", "reason" ]
}
} ]
}

Actual Behavior

Endpoint returns 422

Steps to Reproduce

While using open webui as proxy to ollama, create a json schema to 'format' field.
This typically ensures response is in the specified format. But in this case, open webui api reject the request returning 422.

Logs & Screenshots

ollama: -
open webui:
2025-04-27 14:30:20.351 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 77.169.138.20:49823 - "POST /ollama/api/generate HTTP/1.1" 422 - {}

Additional Information

No response

Originally created by @Umutayb on GitHub (Apr 27, 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 Git Clone ### Open WebUI Version v0.6.5 (latest) ### Ollama Version (if applicable) 0.6.5 ### Operating System Ubuntu 24.04 ### 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 listed steps to reproduce the bug in detail. ### Expected Behavior Open WebUI docker log: 2025-04-27 14:30:20.351 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 77.169.138.20:49823 - "POST /ollama/api/generate HTTP/1.1" 422 - {} Ollama docker log: -- (request does not make it to ollama) While using open webui as proxy to ollama, create a json schema to 'format' field. This typically ensures response is in the specified format. But in this case, open webui api reject the request returning 422. If the same request is sent directly to ollama (which is at a different port), it's successful. Funny enough, if I convert the schema to string, open webui stops complaining but ollama throws a 500 response (invalid schema). I believe there must be an incorrect validation for the /ollama/api/generate endpoint for the schema field. schema does not have to be a string. The request body is: { "model" : "gemma3:27b", "prompt" : "Generic prompt", "stream" : false, "images" : ["hidden" ], "options" : { "temperature" : 1.0, "seed" : 0 }, "format" : { "type" : "object", "properties" : { "pageExplanation" : { "type" : "string" }, "taskComplete" : { "type" : "boolean" }, "reason" : { "type" : "string" } }, "required" : [ "expl", "taskComplete", "reason" ] } } The error body is: { "detail" : [ { "type" : "string_type", "loc" : [ "body", "format" ], "msg" : "Input should be a valid string", "input" : { "type" : "object", "properties" : { "pageExplanation" : { "type" : "string" }, "taskComplete" : { "type" : "boolean" }, "reason" : { "type" : "string" } }, "required" : [ "pageExplanation", "taskComplete", "reason" ] } } ] } ### Actual Behavior Endpoint returns 422 ### Steps to Reproduce While using open webui as proxy to ollama, create a json schema to 'format' field. This typically ensures response is in the specified format. But in this case, open webui api reject the request returning 422. ### Logs & Screenshots ollama: - open webui: 2025-04-27 14:30:20.351 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 77.169.138.20:49823 - "POST /ollama/api/generate HTTP/1.1" 422 - {} ### Additional Information _No response_
GiteaMirror added the bug label 2025-11-11 16:08:31 -06:00
Author
Owner

@tjbck commented on GitHub (Apr 28, 2025):

Addressed with 9bfb4ae8382afb55a009233dd9966bfcefbcb1cd!

@tjbck commented on GitHub (Apr 28, 2025): Addressed with 9bfb4ae8382afb55a009233dd9966bfcefbcb1cd!
Author
Owner

@Umutayb commented on GitHub (Apr 28, 2025):

Awesome!

@Umutayb commented on GitHub (Apr 28, 2025): Awesome!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#4973