{"record":{"id":"1c7a2d3a796981f1","repo":"unclecode/crawl4ai","slug":"invalid-hook-type-hook-type-1c7a2d","errorCode":null,"errorMessage":"Invalid hook type: {hook_type}","messagePattern":"Invalid hook type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"crawl4ai/legacy/crawler_strategy.py","lineNumber":165,"sourceCode":"        # self.service = Service(chromedriver_path)\n        # self.service.log_path = \"NUL\"\n        # self.driver = webdriver.Chrome(service=self.service, options=self.options)\n\n        # Use selenium-manager (built into Selenium 4.10.0+)\n        self.service = Service()\n        self.driver = webdriver.Chrome(options=self.options)\n\n        self.driver = self.execute_hook(\"on_driver_created\", self.driver)\n\n        if kwargs.get(\"cookies\"):\n            for cookie in kwargs.get(\"cookies\"):\n                self.driver.add_cookie(cookie)\n\n    def set_hook(self, hook_type: str, hook: Callable):\n        if hook_type in self.hooks:\n            self.hooks[hook_type] = hook\n        else:\n            raise ValueError(f\"Invalid hook type: {hook_type}\")\n\n    def execute_hook(self, hook_type: str, *args):\n        hook = self.hooks.get(hook_type)\n        if hook:\n            result = hook(*args)\n            if result is not None:\n                if isinstance(result, webdriver.Chrome):\n                    return result\n                else:\n                    raise TypeError(\n                        f\"Hook {hook_type} must return an instance of webdriver.Chrome or None.\"\n                    )\n        # If the hook returns None or there is no hook, return self.driver\n        return self.driver\n\n    def update_user_agent(self, user_agent: str):\n        self.options.add_argument(f\"user-agent={user_agent}\")\n        self.driver.quit()","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/crawl4ai/legacy/crawler_strategy.py#L147-L183","documentation":"Error \"Invalid hook type: {hook_type}\" thrown in unclecode/crawl4ai.","triggerScenarios":"Thrown at crawl4ai/legacy/crawler_strategy.py:165 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use one of the supported hook types (e.g. on_driver_created, before_get_url, after_get_url, before_return_html).","Check the hook name string for typos."],"exampleFix":"crawler_strategy.set_hook('after_get_url', my_hook)","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}