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:
1 parent
799748b886
commit
48f78ca58d
2 files changed
+5
-5
No files matched your search
@@ -42,7 +42,7 @@ class FunctionMeta(BaseModel):
|
|||||||
|
|
||||||
class FunctionModel(BaseModel):
|
class FunctionModel(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
user_id: str
|
user_id: str | None = None # may be null for legacy/malformed records
|
||||||
name: str
|
name: str
|
||||||
type: str
|
type: str
|
||||||
content: str
|
content: str
|
||||||
@@ -58,7 +58,7 @@ class FunctionModel(BaseModel):
|
|||||||
# --- form / schema definitions ---
|
# --- form / schema definitions ---
|
||||||
class FunctionWithValvesModel(BaseModel):
|
class FunctionWithValvesModel(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
user_id: str
|
user_id: str | None = None # may be null for legacy/malformed records
|
||||||
name: str
|
name: str
|
||||||
type: str
|
type: str
|
||||||
content: str
|
content: str
|
||||||
@@ -79,7 +79,7 @@ class FunctionWithValvesModel(BaseModel):
|
|||||||
|
|
||||||
class FunctionResponse(BaseModel):
|
class FunctionResponse(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
user_id: str
|
user_id: str | None = None # may be null for legacy/malformed records
|
||||||
type: str
|
type: str
|
||||||
name: str
|
name: str
|
||||||
meta: FunctionMeta
|
meta: FunctionMeta
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class ToolMeta(BaseModel):
|
|||||||
|
|
||||||
class ToolModel(BaseModel):
|
class ToolModel(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
user_id: str
|
user_id: str | None = None # may be null for legacy/malformed records
|
||||||
name: str
|
name: str
|
||||||
# None when listed with defer_content=True (source skipped for listings)
|
# None when listed with defer_content=True (source skipped for listings)
|
||||||
content: str | None = None
|
content: str | None = None
|
||||||
@@ -66,7 +66,7 @@ class ToolUserModel(ToolModel):
|
|||||||
|
|
||||||
class ToolResponse(BaseModel):
|
class ToolResponse(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
user_id: str
|
user_id: str | None = None # may be null for legacy/malformed records
|
||||||
name: str
|
name: str
|
||||||
meta: ToolMeta
|
meta: ToolMeta
|
||||||
access_grants: list[AccessGrantModel] = Field(default_factory=list)
|
access_grants: list[AccessGrantModel] = Field(default_factory=list)
|
||||||
|
|||||||
Reference in new issue
Block a user