{"record":{"id":"c899a54850974fe0","repo":"D4Vinci/Scrapling","slug":"page-setup-must-be-callable-got-type-self-page-s","errorCode":null,"errorMessage":"page_setup must be callable, got {type(self.page_setup).__name__}","messagePattern":"page_setup must be callable, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"scrapling/engines/_browsers/_validators.py","lineNumber":101,"sourceCode":"    locale: str | None = None\n    real_chrome: bool = False\n    cdp_url: Optional[str] = None\n    useragent: Optional[str] = None\n    extra_flags: Optional[List[str]] = None\n    blocked_domains: Optional[Set[str]] = None\n    block_ads: bool = False\n    retries: RetriesCount = 3\n    retry_delay: Seconds = 1\n    capture_xhr: str | None = None\n    executable_path: Optional[str] = None\n    dns_over_https: bool = False\n\n    def __post_init__(self):  # pragma: no cover\n        \"\"\"Custom validation after msgspec validation\"\"\"\n        if self.page_action and not callable(self.page_action):\n            raise TypeError(f\"page_action must be callable, got {type(self.page_action).__name__}\")\n        if self.page_setup and not callable(self.page_setup):\n            raise TypeError(f\"page_setup must be callable, got {type(self.page_setup).__name__}\")\n        if self.proxy and self.proxy_rotator:\n            raise ValueError(\n                \"Cannot use 'proxy_rotator' together with 'proxy'. \"\n                \"Use either a static proxy or proxy rotation, not both.\"\n            )\n        if self.proxy:\n            self.proxy = construct_proxy_dict(self.proxy)\n        if self.cdp_url:\n            cdp_msg = _is_invalid_cdp_url(self.cdp_url)\n            if cdp_msg:\n                raise ValueError(cdp_msg)\n\n        if not self.cookies:\n            self.cookies = []\n        if not self.extra_flags:\n            self.extra_flags = []\n        if not self.selector_config:\n            self.selector_config = {}","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/D4Vinci/Scrapling/blob/5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f/scrapling/engines/_browsers/_validators.py#L83-L119","documentation":"Same __post_init__ validation as page_action but for `page_setup`: the value must be callable because it is invoked as a callback on the page (page_setup(page)) before navigation. A truthy non-callable (string, dict, result of a call) raises TypeError at config construction.","triggerScenarios":"Passing page_setup as a string name, passing page_setup=setup_page() (calling instead of referencing), or passing a non-function object from dynamic config.","commonSituations":"Config-driven scraper setups where callbacks are serialized, or accidentally adding parentheses when passing the function.","solutions":["Pass the reference: page_setup=my_setup (no parentheses)","Resolve string names from config to real functions before creating the session/fetch params","For async sessions use an async def callback"],"exampleFix":"// before\nsession.fetch(url, page_setup=setup_page())  # calls now, passes result\n\n// after\nsession.fetch(url, page_setup=setup_page)","handlingStrategy":"type-guard","validationCode":"if page_setup is not None and not callable(page_setup):\n    raise TypeError('page_setup must be callable')\nsession.fetch(url, page_setup=page_setup)","typeGuard":"def is_valid_page_setup(fn) -> bool:\n    return fn is None or callable(fn)","tryCatchPattern":"try:\n    session.fetch(url, page_setup=cb)\nexcept TypeError as e:\n    if 'page_setup must be callable' in str(e):\n        cb = resolve_callback(cb); session.fetch(url, page_setup=cb)\n    else:\n        raise","preventionTips":["Pass the function reference (page_setup=setup), not setup()","Resolve serialized callback names before session creation","Use async callbacks with async sessions"],"tags":["validation","callback","typeerror","config"],"backgroundTag":null,"analyzedSha":"5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f","analyzedAt":"2026-08-14T22:23:09.440Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}