fix(gateway): honor default for invalid bool-like config values (#4029)
Co-authored-by: aydnOktay <xaydinoktay@gmail.com>
This commit is contained in:
@@ -27,9 +27,16 @@ def _coerce_bool(value: Any, default: bool = True) -> bool:
|
|||||||
return default
|
return default
|
||||||
if isinstance(value, bool):
|
if isinstance(value, bool):
|
||||||
return value
|
return value
|
||||||
|
if isinstance(value, int):
|
||||||
|
return value != 0
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
return value.strip().lower() in ("true", "1", "yes", "on")
|
lowered = value.strip().lower()
|
||||||
return bool(value)
|
if lowered in ("true", "1", "yes", "on"):
|
||||||
|
return True
|
||||||
|
if lowered in ("false", "0", "no", "off"):
|
||||||
|
return False
|
||||||
|
return default
|
||||||
|
return default
|
||||||
|
|
||||||
|
|
||||||
def _normalize_unauthorized_dm_behavior(value: Any, default: str = "pair") -> str:
|
def _normalize_unauthorized_dm_behavior(value: Any, default: str = "pair") -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user