mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
fix: prevent startup crash when function/tool has null user_id (#26850)
The Function and Tool database columns declare user_id as a nullable String column, but their Pydantic read-models required a non-null string. A record with user_id NULL therefore raised a pydantic ValidationError inside get_functions()/get_tools(), which run during install_tool_and_function_dependencies() at app startup — crashing the whole application and blocking all chat completions. Make user_id Optional in the read/response models so such records validate gracefully (user is already rendered as None downstream when the id has no matching user) instead of taking down startup. Claude-Session: https://claude.ai/code/session_01Y4RRUNq7ZUFkRWbWPkDw3m Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
799748b886
commit
48f78ca58d
2 changed files with 5 additions and 5 deletions
|
|
@ -42,7 +42,7 @@ class FunctionMeta(BaseModel):
|
|||
|
||||
class FunctionModel(BaseModel):
|
||||
id: str
|
||||
user_id: str
|
||||
user_id: str | None = None # may be null for legacy/malformed records
|
||||
name: str
|
||||
type: str
|
||||
content: str
|
||||
|
|
@ -58,7 +58,7 @@ class FunctionModel(BaseModel):
|
|||
# --- form / schema definitions ---
|
||||
class FunctionWithValvesModel(BaseModel):
|
||||
id: str
|
||||
user_id: str
|
||||
user_id: str | None = None # may be null for legacy/malformed records
|
||||
name: str
|
||||
type: str
|
||||
content: str
|
||||
|
|
@ -79,7 +79,7 @@ class FunctionWithValvesModel(BaseModel):
|
|||
|
||||
class FunctionResponse(BaseModel):
|
||||
id: str
|
||||
user_id: str
|
||||
user_id: str | None = None # may be null for legacy/malformed records
|
||||
type: str
|
||||
name: str
|
||||
meta: FunctionMeta
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class ToolMeta(BaseModel):
|
|||
|
||||
class ToolModel(BaseModel):
|
||||
id: str
|
||||
user_id: str
|
||||
user_id: str | None = None # may be null for legacy/malformed records
|
||||
name: str
|
||||
# None when listed with defer_content=True (source skipped for listings)
|
||||
content: str | None = None
|
||||
|
|
@ -66,7 +66,7 @@ class ToolUserModel(ToolModel):
|
|||
|
||||
class ToolResponse(BaseModel):
|
||||
id: str
|
||||
user_id: str
|
||||
user_id: str | None = None # may be null for legacy/malformed records
|
||||
name: str
|
||||
meta: ToolMeta
|
||||
access_grants: list[AccessGrantModel] = Field(default_factory=list)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue