Merge PR #1507: fix: guard validate_params against non-dict input

fix: guard validate_params against non-dict input
This commit is contained in:
Xubin Ren 2026-03-05 00:36:29 +08:00 committed by GitHub
commit a156a8ee93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -54,6 +54,8 @@ class Tool(ABC):
def validate_params(self, params: dict[str, Any]) -> list[str]:
"""Validate tool parameters against JSON schema. Returns error list (empty if valid)."""
if not isinstance(params, dict):
return [f"parameters must be an object, got {type(params).__name__}"]
schema = self.parameters or {}
if schema.get("type", "object") != "object":
raise ValueError(f"Schema must be object type, got {schema.get('type')!r}")