{"record":{"id":"21e09ac0404f535d","repo":"deepset-ai/haystack","slug":"unknown-extraction-mode-string-supported-mode","errorCode":null,"errorMessage":"Unknown extraction mode '{string}'. Supported modes are: {list(enum_map.keys())}","messagePattern":"Unknown extraction mode '(.+?)'\\. Supported modes are: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"haystack/components/converters/pypdf.py","lineNumber":46,"sourceCode":"    PLAIN = \"plain\"\n    LAYOUT = \"layout\"\n\n    def __str__(self) -> str:\n        \"\"\"\n        Convert a PyPDFExtractionMode enum to a string.\n        \"\"\"\n        return self.value\n\n    @staticmethod\n    def from_str(string: str) -> \"PyPDFExtractionMode\":\n        \"\"\"\n        Convert a string to a PyPDFExtractionMode enum.\n        \"\"\"\n        enum_map = {e.value: e for e in PyPDFExtractionMode}\n        mode = enum_map.get(string)\n        if mode is None:\n            msg = f\"Unknown extraction mode '{string}'. Supported modes are: {list(enum_map.keys())}\"\n            raise ValueError(msg)\n        return mode\n\n\n@component\nclass PyPDFToDocument:\n    \"\"\"\n    Converts PDF files to documents your pipeline can query.\n\n    This component uses the PyPDF library.\n    You can attach metadata to the resulting documents.\n\n    ### Usage example\n\n    ```python\n    from haystack.components.converters.pypdf import PyPDFToDocument\n    from datetime import datetime\n\n    converter = PyPDFToDocument()","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/converters/pypdf.py#L28-L64","documentation":"PyPDFExtractionMode.from_str converts a user-supplied string into a PyPDFExtractionMode enum by looking it up in a value-keyed map. If the string does not exactly match one of the enum's values, a ValueError listing the valid modes is raised. This guards the PyPDFToDocument component against invalid extraction-mode configuration at pipeline-construction time.","triggerScenarios":"Passing a string to PyPDFExtractionMode.from_str (or the extraction_mode init/run parameter of PyPDFToDocument, which resolves through it) that is not an exact match for an enum value, e.g. 'plain_text', 'text', or 'TEXT' instead of 'plain'.","commonSituations":"Typo in YAML/JSON pipeline config; using an outdated mode name after an enum value change; assuming case-insensitive lookup (lookup is case-sensitive); copying examples from older haystack versions.","solutions":["Check the exact supported values in the message (e.g. ['plain','layout']) and use one verbatim, lowercase.","If using PyPDFToDocument, pass extraction_mode='plain' or 'layout' exactly as documented.","If the mode name came from an old pipeline YAML, update the config to the current enum value."],"exampleFix":"# before\nconverter = PyPDFToDocument(extraction_mode=\"text\")\n# after\nfrom haystack.components.converters.pypdf import PyPDFExtractionMode\nconverter = PyPDFToDocument(extraction_mode=\"layout\")  # or PyPDFExtractionMode.LAYOUT","handlingStrategy":"validation","validationCode":"from haystack.components.converters.pypdf import PyPDFExtractionMode\n\ndef is_valid_mode(mode: str) -> bool:\n    return mode in {e.value for e in PyPDFExtractionMode}\n\nassert is_valid_mode(extraction_mode), f\"{extraction_mode!r} not in {sorted(e.value for e in PyPDFExtractionMode)}\"","typeGuard":"from typing import Literal\nfrom haystack.components.converters.pypdf import PyPDFExtractionMode\n\nModeLiteral = Literal[tuple(PyPDFExtractionMode.__members__)]  # ('plain', 'layout')\n\ndef is_extraction_mode(s: str) -> bool:\n    return s in {e.value for e in PyPDFExtractionMode}","tryCatchPattern":"try:\n    converter = PyPDFToDocument(extraction_mode=mode)\nexcept ValueError as e:\n    logger.error(\"Bad extraction_mode %s: %s\", mode, e)\n    converter = PyPDFToDocument()  # default 'plain'","preventionTips":["Keep mode strings centralized as PyPDFExtractionMode enum members instead of raw strings","Enable mypy Literal typing on config loaders to catch typos before runtime","Add a unit test that parses your pipeline YAML and constructs every component"],"tags":["python","valueerror","enum","invalid-argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}