{"record":{"id":"2a27fba828c0958f","repo":"unclecode/crawl4ai","slug":"extraction-strategy-must-be-an-instance-of-extract-2a27fb","errorCode":null,"errorMessage":"extraction_strategy must be an instance of ExtractionStrategy","messagePattern":"extraction_strategy must be an instance of ExtractionStrategy","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"crawl4ai/async_configs.py:1841","lineNumber":1009,"sourceCode":"\n        # Connection Parameters\n        self.stream = stream\n        self.method = method\n\n        # Robots.txt Handling Parameters\n        self.check_robots_txt = check_robots_txt\n\n        # User Agent Parameters\n        self.user_agent = user_agent\n        self.user_agent_mode = user_agent_mode\n        self.user_agent_generator_config = user_agent_generator_config\n\n        # Validate type of extraction strategy and chunking strategy if they are provided\n        if self.extraction_strategy is not None and not isinstance(\n            self.extraction_strategy, ExtractionStrategy\n        ):\n            raise ValueError(\n                \"extraction_strategy must be an instance of ExtractionStrategy\"\n            )\n        if self.chunking_strategy is not None and not isinstance(\n            self.chunking_strategy, ChunkingStrategy\n        ):\n            raise ValueError(\n                \"chunking_strategy must be an instance of ChunkingStrategy\"\n            )\n\n        # Set default chunking strategy if None\n        if self.chunking_strategy is None:\n            self.chunking_strategy = RegexChunking()\n\n        # Deep Crawl Parameters\n        self.deep_crawl_strategy = deep_crawl_strategy\n        \n        # Experimental Parameters\n        self.experimental = experimental or {}\n","sourceCodeStart":991,"sourceCodeEnd":1027,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/deploy/docker/c4ai-code-context.md#L991-L1027","documentation":"ValueError from CrawlerRunConfig.__init__: extraction_strategy was supplied but is not an instance of ExtractionStrategy (and not None). The config validates early so failures appear at setup rather than mid-crawl.","triggerScenarios":"arun(url, config=CrawlerRunConfig(extraction_strategy='css')) or passing a class instead of an instance (extraction_strategy=JsonCssExtractionStrategy - missing parentheses), or a custom object not subclassing ExtractionStrategy.","commonSituations":"Forgetting to instantiate the strategy class; passing a dict of strategy params hoping the crawler builds it; migrating old code where a string name used to work via a different API; duck-typed custom strategy that never subclassed the base.","solutions":["Instantiate: extraction_strategy=JsonCssExtractionStrategy(schema=...)","For custom strategies, subclass crawl4ai.extraction_strategy.ExtractionStrategy and implement its abstract methods","Pass None (default) when you do not want extraction"],"exampleFix":"# before\nconfig = CrawlerRunConfig(extraction_strategy=JsonCssExtractionStrategy)\n\n# after\nfrom crawl4ai import JsonCssExtractionStrategy\nconfig = CrawlerRunConfig(\n    extraction_strategy=JsonCssExtractionStrategy(schema={\"baseSelector\": \"a\", \"fields\": []})\n)","handlingStrategy":"type-guard","validationCode":"from crawl4ai.extraction_strategy import ExtractionStrategy\nassert extraction_strategy is None or isinstance(extraction_strategy, ExtractionStrategy), \"extraction_strategy must be an ExtractionStrategy instance\"","typeGuard":"from crawl4ai.extraction_strategy import ExtractionStrategy\n\ndef is_extraction_strategy(s) -> bool:\n    return s is None or isinstance(s, ExtractionStrategy)","tryCatchPattern":"try:\n    config = CrawlerRunConfig(extraction_strategy=strat)\nexcept ValueError:\n    raise TypeError(\"extraction strategies must be instantiated ExtractionStrategy subclasses\")","preventionTips":["Always instantiate strategy classes at config build time","For custom strategies, subclass ExtractionStrategy and implement the abstract interface before first use"],"tags":["crawl4ai","config","validation","extraction"],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}