fix: bool('false') is True coerces endpoint toggles incorrectly (#2361)
Python's bool('false') returns True because the string is non-empty.
A JS client serialising a boolean as the string 'false' would have
supports_tools or is_enabled silently flipped to True — so 'disable
tool support' would actually enable it.
Use an explicit lookup dict for supports_tools and a case-insensitive
string check for is_enabled so both string and native bool inputs are
handled correctly.
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1899,9 +1899,10 @@ def setup_model_routes(model_discovery):
|
||||
if body:
|
||||
if "supports_tools" in body:
|
||||
v = body["supports_tools"]
|
||||
ep.supports_tools = bool(v) if v in (True, False, "true", "false", 1, 0) else None
|
||||
ep.supports_tools = {True: True, False: False, 'true': True, 'false': False, 1: True, 0: False}.get(v)
|
||||
if "is_enabled" in body:
|
||||
ep.is_enabled = bool(body["is_enabled"])
|
||||
v_ie = body['is_enabled']
|
||||
ep.is_enabled = v_ie.lower() in ('true', '1', 'yes') if isinstance(v_ie, str) else bool(v_ie)
|
||||
if "name" in body and isinstance(body["name"], str):
|
||||
ep.name = body["name"].strip() or ep.name
|
||||
if "model_type" in body and isinstance(body["model_type"], str):
|
||||
|
||||
Reference in New Issue
Block a user