{"record":{"id":"9c40db705d6a641a","repo":"D4Vinci/Scrapling","slug":"unknown-extraction-type-extraction-type","errorCode":null,"errorMessage":"Unknown extraction type: {extraction_type}","messagePattern":"Unknown extraction type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scrapling/core/shell.py","lineNumber":628,"sourceCode":"            if element.text:\n                element.text = _CONTROL_CHARS_PATTERN.sub(\"\", _ZWC_PATTERN.sub(\"\", element.text))\n            if element.tail:\n                element.tail = _CONTROL_CHARS_PATTERN.sub(\"\", _ZWC_PATTERN.sub(\"\", element.tail))\n        return Selector(root=clean_root, url=page.url, keep_comments=False)\n\n    @classmethod\n    def _extract_content(\n        cls,\n        page: Selector,\n        extraction_type: extraction_types = \"markdown\",\n        css_selector: Optional[str] = None,\n        main_content_only: bool = False,\n    ) -> Generator[str, None, None]:\n        \"\"\"Extract the content of a Selector\"\"\"\n        if not page or not isinstance(page, Selector):  # pragma: no cover\n            raise TypeError(\"Input must be of type `Selector`\")\n        elif not extraction_type or extraction_type not in cls._extension_map.values():\n            raise ValueError(f\"Unknown extraction type: {extraction_type}\")\n        else:\n            if main_content_only:\n                page = cast(Selector, page.css(\"body\").first) or page\n                page = cls._strip_noise_tags(page)\n                page = cls._sanitize_for_ai(page)\n\n            pages = [page] if not css_selector else cast(Selectors, page.css(css_selector))\n            for page in pages:\n                match extraction_type:\n                    case \"markdown\":\n                        yield cls._convert_to_markdown(page.html_content)\n                    case \"html\":\n                        yield page.html_content\n                    case \"text\":\n                        txt_content = page.get_all_text(\n                            strip=True, ignore_tags=(\"script\", \"style\", \"noscript\", \"svg\", \"iframe\")\n                        )\n                        for s in (","sourceCodeStart":610,"sourceCodeEnd":646,"githubUrl":"https://github.com/D4Vinci/Scrapling/blob/5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f/scrapling/core/shell.py#L610-L646","documentation":"_extract_content validates extraction_type against the values of Convertor._extension_map (markdown/html/text-family) before dispatching via a match statement. An empty string or a value not in the map raises ValueError rather than falling through silently. This mirrors the CLI's file-extension driven types.","triggerScenarios":"Calling _extract_content with extraction_type='xml', 'json', '' or a typo like 'md' or 'Markdown' (case matters). The CLI only passes values derived from the output file extension (.md/.html/.txt), so this mostly bites direct callers.","commonSituations":"Passing a file extension ('md') instead of the type name ('markdown'), or assuming formats beyond the three supported ones exist.","solutions":["Use one of the exact values: 'markdown', 'html', or the text type defined in _extension_map","Check Convertor._extension_map for the accepted set if unsure","Prefer the public write_content_to_file with the right file extension, which maps the type for you"],"exampleFix":"# before\nConvertor._extract_content(page, 'md')\n\n# after\nConvertor._extract_content(page, 'markdown')","handlingStrategy":"validation","validationCode":"valid_types = set(Convertor._extension_map.values())\nextraction_type = extraction_type if extraction_type in valid_types else 'markdown'","typeGuard":"from typing import Any\n\ndef is_extraction_type(value: Any) -> bool:\n    return isinstance(value, str) and value in {'markdown', 'html', 'text'}","tryCatchPattern":null,"preventionTips":["Pass full type names ('markdown'), not file extensions ('md')","Derive the type from write_content_to_file's extension map instead of hardcoding"],"tags":["shell","internal-api","validation","extraction"],"backgroundTag":null,"analyzedSha":"5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f","analyzedAt":"2026-08-14T22:23:09.440Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}