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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user