{"record":{"id":"fc821dfda553682d","repo":"SeleniumHQ/selenium","slug":"autodetect-proxy-value-needs-to-be-a-boolean","errorCode":null,"errorMessage":"Autodetect proxy value needs to be a boolean","messagePattern":"Autodetect proxy value needs to be a boolean","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/common/proxy.py","lineNumber":68,"sourceCode":"        value = str(value).upper()\n        for attr in dir(cls):\n            attr_value = getattr(cls, attr)\n            if isinstance(attr_value, dict) and \"string\" in attr_value and attr_value[\"string\"] == value:\n                return attr_value\n        raise Exception(f\"No proxy type is found for {value}\")\n\n\nclass _ProxyTypeDescriptor:\n    def __init__(self, name, p_type):\n        self.name = name\n        self.p_type = p_type\n\n    def __get__(self, obj, cls):\n        return getattr(obj, self.name)\n\n    def __set__(self, obj, value):\n        if self.name == \"autodetect\" and not isinstance(value, bool):\n            raise ValueError(\"Autodetect proxy value needs to be a boolean\")\n        getattr(obj, \"_verify_proxy_type_compatibility\")(self.p_type)\n        setattr(obj, \"proxyType\", self.p_type)\n        setattr(obj, self.name, value)\n\n\nclass Proxy:\n    \"\"\"Proxy configuration containing proxy type and necessary proxy settings.\"\"\"\n\n    proxyType = ProxyType.UNSPECIFIED\n    autodetect = False\n    httpProxy = \"\"\n    noProxy = \"\"\n    proxyAutoconfigUrl = \"\"\n    sslProxy = \"\"\n    socksProxy = \"\"\n    socksUsername = \"\"\n    socksPassword = \"\"\n    socksVersion = None","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/common/proxy.py#L50-L86","documentation":"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.","triggerScenarios":"Setting proxy.auto_detect = 'true' (string), proxy.auto_detect = 1, or proxy.auto_detect = 'yes'. Assigning from config/env that yields a string.","commonSituations":"Loading 'autodetect' from JSON/YAML as a string. Using truthy ints. Environment-variable parsing returning strings.","solutions":["Pass a real bool: proxy.auto_detect = True.","Convert string config: proxy.auto_detect = (val.lower() == 'true')."],"exampleFix":"# before\nproxy.auto_detect = 'true'  # str -> ValueError\n\n# after\nproxy.auto_detect = True\n# from config string\nproxy.auto_detect = (config_val.strip().lower() in ('true', '1', 'yes'))","handlingStrategy":"type-guard","validationCode":"if not isinstance(auto_val, bool):\n    auto_val = str(auto_val).strip().lower() in ('true','1','yes')\nproxy.auto_detect = auto_val","typeGuard":"def is_bool(v) -> bool:\n    return isinstance(v, bool)","tryCatchPattern":"try:\n    proxy.auto_detect = val\nexcept ValueError:\n    proxy.auto_detect = bool(val)","preventionTips":["Normalize string config to bool at the boundary.","Never pass ints as boolean proxy flags."],"tags":["proxy","type-validation","autodetect","boolean"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}