mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 06:03:26 -05:00
Incorrect validation for 'format' field while calling the '/ollama/api/generate' endpoint #4973
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?
Originally created by @Umutayb on GitHub (Apr 27, 2025).
Check Existing Issues
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
README.md.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
@tjbck commented on GitHub (Apr 28, 2025):
Addressed with 9bfb4ae8382afb55a009233dd9966bfcefbcb1cd!
@Umutayb commented on GitHub (Apr 28, 2025):
Awesome!