{"record":{"id":"7277852f6c0b6e5d","repo":"SeleniumHQ/selenium","slug":"raw-must-be-a-dict-got-type-raw","errorCode":null,"errorMessage":"`raw` must be a dict, got {type(raw)}","messagePattern":"`raw` must be a dict, got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/common/proxy.py","lineNumber":125,"sourceCode":"    socks_username = _ProxyTypeDescriptor(\"socksUsername\", ProxyType.MANUAL)\n    \"\"\"SOCKS proxy username.\"\"\"\n\n    socks_password = _ProxyTypeDescriptor(\"socksPassword\", ProxyType.MANUAL)\n    \"\"\"SOCKS proxy password.\"\"\"\n\n    socks_version = _ProxyTypeDescriptor(\"socksVersion\", ProxyType.MANUAL)\n    \"\"\"SOCKS proxy version.\"\"\"\n\n    def __init__(self, raw: dict | None = None):\n        \"\"\"Creates a new Proxy.\n\n        Args:\n            raw: Raw proxy data. If None, default class values are used.\n        \"\"\"\n        if raw is None:\n            return\n        if not isinstance(raw, dict):\n            raise TypeError(f\"`raw` must be a dict, got {type(raw)}\")\n        if raw.get(\"proxyType\"):\n            self.proxy_type = ProxyType.load(raw[\"proxyType\"])\n        if raw.get(\"httpProxy\"):\n            self.http_proxy = raw[\"httpProxy\"]\n        if raw.get(\"noProxy\"):\n            self.no_proxy = raw[\"noProxy\"]\n        if raw.get(\"proxyAutoconfigUrl\"):\n            self.proxy_autoconfig_url = raw[\"proxyAutoconfigUrl\"]\n        if raw.get(\"sslProxy\"):\n            self.sslProxy = raw[\"sslProxy\"]\n        if raw.get(\"autodetect\"):\n            self.auto_detect = raw[\"autodetect\"]\n        if raw.get(\"socksProxy\"):\n            self.socks_proxy = raw[\"socksProxy\"]\n        if raw.get(\"socksUsername\"):\n            self.socks_username = raw[\"socksUsername\"]\n        if raw.get(\"socksPassword\"):\n            self.socks_password = raw[\"socksPassword\"]","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/common/proxy.py#L107-L143","documentation":"The Proxy constructor accepts an optional `raw` argument that must be either None (use defaults) or a dict. Any other type raises TypeError naming the received type. The dict is then interpreted as a raw proxy-capability map (proxyType, httpProxy, noProxy, etc.).","triggerScenarios":"Calling Proxy('MANUAL'), Proxy([('httpProxy','host')], Proxy(123), or Proxy(json_string). Passing a JSON-decoded value that is a list or scalar instead of an object.","commonSituations":"Passing a JSON string instead of a parsed dict. Passing a list of tuples. Passing another Proxy instance instead of its capabilities.","solutions":["Pass a dict (or None): Proxy({'httpProxy': 'host:8080'}).","If you have a JSON string, json.loads() it first.","To copy a Proxy, pass proxy.to_capabilities()."],"exampleFix":"# before\np = Proxy('{\"httpProxy\": \"host:8080\"}')  # str -> TypeError\n\n# after\nimport json\np = Proxy(json.loads('{\"httpProxy\": \"host:8080\"}'))\n# or directly\np = Proxy({'httpProxy': 'host:8080'})","handlingStrategy":"type-guard","validationCode":"import json\nif isinstance(raw, str):\n    raw = json.loads(raw)\nif raw is not None and not isinstance(raw, dict):\n    raise TypeError('raw must be a dict or None')\nproxy = Proxy(raw)","typeGuard":"def is_proxy_raw(v) -> bool:\n    return v is None or isinstance(v, dict)","tryCatchPattern":"try:\n    proxy = Proxy(raw)\nexcept TypeError:\n    proxy = Proxy(raw if isinstance(raw, dict) else None)","preventionTips":["json.loads() JSON strings before passing to Proxy.","Pass dicts only; never scalars, lists, or other Proxy instances."],"tags":["proxy","type-validation","constructor"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}