D4Vinci/Scrapling · error · TypeError
Argument `selector_config` must be a dictionary.
Error message
Argument `selector_config` must be a dictionary.
What it means
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.
Source
Thrown at scrapling/fetchers/stealth_chrome.py:58
:param hide_canvas: Add random noise to canvas operations to prevent fingerprinting.
:param block_webrtc: Forces WebRTC to respect proxy settings to prevent local IP address leak.
: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.
:param load_dom: Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
:param cdp_url: Instead of launching a new browser instance, connect to this CDP URL to control real browsers through CDP.
:param google_search: Enabled by default, Scrapling will set a Google referer header.
: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._
: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.
: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.
:param extra_flags: A list of additional browser flags to pass to the browser on launch.
:param selector_config: The arguments that will be passed in the end while creating the final Selector's class.
:param additional_args: Additional arguments to be passed to Playwright's context as additional settings, and it takes higher priority than Scrapling's settings.
:return: A `Response` object.
"""
selector_config = kwargs.get("selector_config", {}) or kwargs.get(
"custom_config", {}
) # Checking `custom_config` for backward compatibility
if not isinstance(selector_config, dict):
raise TypeError("Argument `selector_config` must be a dictionary.")
kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config}
with StealthySession(**kwargs) as engine:
return engine.fetch(url)
@classmethod
async def async_fetch(cls, url: str, **kwargs: Unpack[StealthSession]) -> Response:
"""
Opens up a browser and do your request based on your chosen options below.
:param url: Target url.
:param headless: Run the browser in headless/hidden (default), or headful/visible mode.
:param disable_resources: Drop requests for unnecessary resources for a speed boost.
Requests dropped are of type `font`, `image`, `media`, `beacon`, `object`, `imageset`, `texttrack`, `websocket`, `csp_report`, and `stylesheet`.
: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).
:param block_ads: Block requests to ~3,500 known ad/tracking domains. Can be combined with ``blocked_domains``.
:param dns_over_https: Route DNS queries through Cloudflare's DNS-over-HTTPS to prevent DNS leaks when using proxies.View on GitHub (pinned to 5d213a2d47)
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.
Example fix
# before
StealthyFetcher.fetch(url, selector_config=('adaptive', True))
# after
StealthyFetcher.fetch(url, selector_config={'adaptive': True}) Defensive patterns
Strategy: validation
Validate before calling
from dataclasses import asdict, is_dataclass
if is_dataclass(selector_config):
selector_config = asdict(selector_config)
assert isinstance(selector_config, dict)
StealthyFetcher.fetch(url, selector_config=selector_config) Type guard
def is_selector_config(value: object) -> bool:
return isinstance(value, dict) Try / catch
try:
StealthyFetcher.fetch(url, selector_config=cfg)
except TypeError as e:
if "selector_config" in str(e):
return StealthyFetcher.fetch(url, selector_config=dict(cfg))
raise Prevention
- 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.
When it happens
Trigger: StealthyFetcher.fetch(url, selector_config=SomeConfigObject()), selector_config=['adaptive'], or custom_config='keep_comments=True'.
Common situations: 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.
Related errors
- Argument `selector_config` must be a dictionary.
- Response meta should be dictionary but got {type(meta).__nam
- Unknown parser argument: "{key}"; maybe you meant {cls.parse
- Invalid proxy string: {proxy_string}
- strategy must be callable, got {type(strategy).__name__}
AI-assisted analysis of D4Vinci/Scrapling@5d213a2d47 (2026-08-14).
Data as JSON: /api/errors/029fd83cad02ccb5.
Report an issue: GitHub.