{"record":{"id":"029fd83cad02ccb5","repo":"D4Vinci/Scrapling","slug":"argument-selector-config-must-be-a-dictionary-029fd8","errorCode":null,"errorMessage":"Argument `selector_config` must be a dictionary.","messagePattern":"Argument `selector_config` must be a dictionary\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"scrapling/fetchers/stealth_chrome.py","lineNumber":58,"sourceCode":"        :param hide_canvas: Add random noise to canvas operations to prevent fingerprinting.\n        :param block_webrtc: Forces WebRTC to respect proxy settings to prevent local IP address leak.\n        :param allow_webgl: Enabled by default. Disabling it disables WebGL and WebGL 2.0 support entirely. Disabling WebGL is not recommended as many WAFs now check if WebGL is enabled.\n        :param load_dom: Enabled by default, wait for all JavaScript on page(s) to fully load and execute.\n        :param cdp_url: Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.\n        :param google_search: Enabled by default, Scrapling will set a Google referer header.\n        :param extra_headers: A dictionary of extra headers to add to the request. _The referer set by `google_search` takes priority over the referer set here if used together._\n        :param proxy: The proxy to be used with requests, it can be a string or a dictionary with the keys 'server', 'username', and 'password' only.\n        :param user_data_dir: Path to a User Data Directory, which stores browser session data like cookies and local storage. The default is to create a temporary directory.\n        :param extra_flags: A list of additional browser flags to pass to the browser on launch.\n        :param selector_config: The arguments that will be passed in the end while creating the final Selector's class.\n        :param additional_args: Additional arguments to be passed to Playwright's context as additional settings, and it takes higher priority than Scrapling's settings.\n        :return: A `Response` object.\n        \"\"\"\n        selector_config = kwargs.get(\"selector_config\", {}) or kwargs.get(\n            \"custom_config\", {}\n        )  # Checking `custom_config` for backward compatibility\n        if not isinstance(selector_config, dict):\n            raise TypeError(\"Argument `selector_config` must be a dictionary.\")\n\n        kwargs[\"selector_config\"] = {**cls._generate_parser_arguments(), **selector_config}\n\n        with StealthySession(**kwargs) as engine:\n            return engine.fetch(url)\n\n    @classmethod\n    async def async_fetch(cls, url: str, **kwargs: Unpack[StealthSession]) -> Response:\n        \"\"\"\n        Opens up a browser and do your request based on your chosen options below.\n\n        :param url: Target url.\n        :param headless: Run the browser in headless/hidden (default), or headful/visible mode.\n        :param disable_resources: Drop requests for unnecessary resources for a speed boost.\n            Requests dropped are of type `font`, `image`, `media`, `beacon`, `object`, `imageset`, `texttrack`, `websocket`, `csp_report`, and `stylesheet`.\n        :param blocked_domains: A set of domain names to block requests to. Subdomains are also matched (e.g., ``\"example.com\"`` blocks ``\"sub.example.com\"`` too).\n        :param block_ads: Block requests to ~3,500 known ad/tracking domains. Can be combined with ``blocked_domains``.\n        :param dns_over_https: Route DNS queries through Cloudflare's DNS-over-HTTPS to prevent DNS leaks when using proxies.","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/D4Vinci/Scrapling/blob/5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f/scrapling/fetchers/stealth_chrome.py#L40-L76","documentation":"Raised by `StealthyFetcher.fetch` (scrapling/fetchers/stealth_chrome.py) when `selector_config` (or the legacy `custom_config` key) resolves to a non-dict value. Identical contract to the other fetchers: the value is merged over generated parser arguments and must be a mapping of Selector kwargs.","triggerScenarios":"StealthyFetcher.fetch(url, selector_config=SomeConfigObject()), selector_config=['adaptive'], or custom_config='keep_comments=True'.","commonSituations":"Camoufox/stealth setups where users build a settings object elsewhere; converting working DynamicFetcher configs into a shared object that loses dict-ness; config loaded from YAML producing a list of pairs.","solutions":["Pass a plain dict of Selector kwargs: StealthyFetcher.fetch(url, selector_config={'adaptive': True}).","Convert objects via dataclasses.asdict()/vars() before the call.","Prefer the current name selector_config over the deprecated custom_config."],"exampleFix":"# before\nStealthyFetcher.fetch(url, selector_config=('adaptive', True))\n\n# after\nStealthyFetcher.fetch(url, selector_config={'adaptive': True})","handlingStrategy":"validation","validationCode":"from dataclasses import asdict, is_dataclass\nif is_dataclass(selector_config):\n    selector_config = asdict(selector_config)\nassert isinstance(selector_config, dict)\nStealthyFetcher.fetch(url, selector_config=selector_config)","typeGuard":"def is_selector_config(value: object) -> bool:\n    return isinstance(value, dict)","tryCatchPattern":"try:\n    StealthyFetcher.fetch(url, selector_config=cfg)\nexcept TypeError as e:\n    if \"selector_config\" in str(e):\n        return StealthyFetcher.fetch(url, selector_config=dict(cfg))\n    raise","preventionTips":["Pass Selector kwargs as a dict, not objects/strings/tuples.","Prefer selector_config over the deprecated custom_config key.","Validate config type once in a shared wrapper around fetch calls."],"tags":["fetcher","stealth","selector-config","type-error","validation"],"backgroundTag":null,"analyzedSha":"5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f","analyzedAt":"2026-08-14T22:23:09.440Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}