SeleniumHQ/selenium · error · ValueError
Autodetect proxy value needs to be a boolean
Error message
Autodetect proxy value needs to be a boolean
What it means
The auto_detect property is backed by _ProxyTypeDescriptor with name 'autodetect', which requires a bool. Assigning any non-bool (string 'true', int 1, None) raises ValueError. Setting auto_detect also flips the proxyType to AUTODETECT via the descriptor.
Source
Thrown at py/selenium/webdriver/common/proxy.py:68
value = str(value).upper()
for attr in dir(cls):
attr_value = getattr(cls, attr)
if isinstance(attr_value, dict) and "string" in attr_value and attr_value["string"] == value:
return attr_value
raise Exception(f"No proxy type is found for {value}")
class _ProxyTypeDescriptor:
def __init__(self, name, p_type):
self.name = name
self.p_type = p_type
def __get__(self, obj, cls):
return getattr(obj, self.name)
def __set__(self, obj, value):
if self.name == "autodetect" and not isinstance(value, bool):
raise ValueError("Autodetect proxy value needs to be a boolean")
getattr(obj, "_verify_proxy_type_compatibility")(self.p_type)
setattr(obj, "proxyType", self.p_type)
setattr(obj, self.name, value)
class Proxy:
"""Proxy configuration containing proxy type and necessary proxy settings."""
proxyType = ProxyType.UNSPECIFIED
autodetect = False
httpProxy = ""
noProxy = ""
proxyAutoconfigUrl = ""
sslProxy = ""
socksProxy = ""
socksUsername = ""
socksPassword = ""
socksVersion = NoneView on GitHub (pinned to aa36b38e69)
Solutions
- Pass a real bool: proxy.auto_detect = True.
- Convert string config: proxy.auto_detect = (val.lower() == 'true').
Example fix
# before
proxy.auto_detect = 'true' # str -> ValueError
# after
proxy.auto_detect = True
# from config string
proxy.auto_detect = (config_val.strip().lower() in ('true', '1', 'yes')) Defensive patterns
Strategy: type-guard
Validate before calling
if not isinstance(auto_val, bool):
auto_val = str(auto_val).strip().lower() in ('true','1','yes')
proxy.auto_detect = auto_val Type guard
def is_bool(v) -> bool:
return isinstance(v, bool) Try / catch
try:
proxy.auto_detect = val
except ValueError:
proxy.auto_detect = bool(val) Prevention
- Normalize string config to bool at the boundary.
- Never pass ints as boolean proxy flags.
When it happens
Trigger: Setting proxy.auto_detect = 'true' (string), proxy.auto_detect = 1, or proxy.auto_detect = 'yes'. Assigning from config/env that yields a string.
Common situations: Loading 'autodetect' from JSON/YAML as a string. Using truthy ints. Environment-variable parsing returning strings.
Related errors
- Only Proxy objects can be passed in.
- `raw` must be a dict, got {type(raw)}
- no_proxy list must contain only strings
- no_proxy must be a comma-separated string or a list of strin
- Please pass in a Boolean to this call
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/fc821dfda553682d.
Report an issue: GitHub.