{"record":{"id":"218bc003bf2cf2bd","repo":"unclecode/crawl4ai","slug":"extraction-strategy-must-be-an-instance-of-extract","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","lineNumber":1841,"sourceCode":"        # Connection Parameters\n        self.stream = stream\n        self.prefetch = prefetch  # Prefetch mode: return only HTML + links\n        self.process_in_browser = process_in_browser  # Force browser processing for raw:/file:// URLs\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        if self.markdown_generator is not None and not isinstance(\n            self.markdown_generator, MarkdownGenerationStrategy\n        ):\n            hint = \"\"\n            if isinstance(self.markdown_generator, dict):\n                hint = (\n                    ' The JSON format must be {\"type\": \"<ClassName>\", \"params\": {...}}.'\n                    ' Note: \"params\" is required — \"options\" or other keys are not recognized.'\n                )\n            raise ValueError(","sourceCodeStart":1823,"sourceCodeEnd":1859,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/crawl4ai/async_configs.py#L1823-L1859","documentation":"CrawlerRunConfig.__post_init__-style validation: extraction_strategy must be an instance of ExtractionStrategy (e.g. JsonCssExtractionStrategy, LLMExtractionStrategy) or None. Strings, dicts, or arbitrary callables are rejected because the crawler invokes strategy-specific methods (extract, run) on it.","triggerScenarios":"Passing extraction_strategy=\"JsonCssExtractionStrategy\" (class name string), a raw dict schema, or an uninitialized class reference instead of an instance.","commonSituations":"Loading config from JSON/YAML and passing it through unserialized; copy-pasting docs that show the class rather than an instance; confusion between class and instance.","solutions":["Instantiate the strategy: extraction_strategy=JsonCssExtractionStrategy(schema)","If loading from a dict, use the {'type': 'ClassName', 'params': {...}} serialization format and from_serializable_dict / CrawlerRunConfig.from_kwargs which auto-deserializes it","Pass None (or omit) when you do not want an extraction strategy"],"exampleFix":"// before\ncfg = CrawlerRunConfig(extraction_strategy=\"JsonCssExtractionStrategy\")\n// after\nfrom crawl4ai import JsonCssExtractionStrategy\ncfg = CrawlerRunConfig(extraction_strategy=JsonCssExtractionStrategy(schema=my_schema))","handlingStrategy":"type-guard","validationCode":"from crawl4ai.extraction_strategy import ExtractionStrategy\n\nif isinstance(extraction_strategy, dict):\n    extraction_strategy = CrawlerRunConfig.from_kwargs(\n        {\"extraction_strategy\": extraction_strategy}\n    ).extraction_strategy","typeGuard":"from crawl4ai.extraction_strategy import ExtractionStrategy\n\ndef is_extraction_strategy(v) -> bool:\n    return v is None or isinstance(v, ExtractionStrategy)","tryCatchPattern":"try:\n    CrawlerRunConfig(extraction_strategy=v)\nexcept ValueError as e:\n    if \"extraction_strategy\" in str(e):\n        v = deserialize_strategy(v)  # {'type','params'} -> instance\n    else:\n        raise","preventionTips":["Always instantiate strategies, never pass class names","Route dict configs through CrawlerRunConfig.from_kwargs"],"tags":["validation","extraction","configuration","type-error"],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}