{"record":{"id":"02b00d59d420c983","repo":"docling-project/docling","slug":"preset-preset-id-not-found-for-cls-name","errorCode":null,"errorMessage":"Preset '{preset_id}' not found for {cls.__name__}. Available presets: {list(cls._presets.keys())}","messagePattern":"Preset '(.+?)' not found for (.+?)\\. Available presets: (.+?)","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"docling/datamodel/stage_model_specs.py","lineNumber":581,"sourceCode":"            _log.error(\n                f\"Preset '{preset.preset_id}' already registered for {cls.__name__}\"\n            )\n\n    @classmethod\n    def get_preset(cls, preset_id: str) -> StageModelPreset:\n        \"\"\"Get a specific preset.\n\n        Args:\n            preset_id: The preset identifier\n\n        Returns:\n            The requested preset\n\n        Raises:\n            KeyError: If preset not found\n        \"\"\"\n        if preset_id not in cls._presets:\n            raise KeyError(\n                f\"Preset '{preset_id}' not found for {cls.__name__}. \"\n                f\"Available presets: {list(cls._presets.keys())}\"\n            )\n        return cls._presets[preset_id]\n\n    @classmethod\n    def list_presets(cls) -> List[StageModelPreset]:\n        \"\"\"List all presets for this stage.\n\n        Returns:\n            List of presets\n        \"\"\"\n        return list(cls._presets.values())\n\n    @classmethod\n    def list_preset_ids(cls) -> List[str]:\n        \"\"\"List all preset IDs for this stage.\n","sourceCodeStart":563,"sourceCodeEnd":599,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/datamodel/stage_model_specs.py#L563-L599","documentation":"Stage classes using the generic preset mixin expose get_preset(preset_id), which raises KeyError when the requested preset id is not in the class's registered _presets registry. Presets are registered explicitly via register_preset, so an unknown or unregistered id — including typos and version-removed presets — fails here. The message lists the available preset ids for that class.","triggerScenarios":"Calling SomeStage.get_preset('my_preset') (or from_preset('my_preset')) where 'my_preset' was never registered on that class; using a preset id that exists on a different stage class; registering the preset after the lookup or not at all.","commonSituations":"Typos in preset ids from hand-written config strings; upgrading docling where a preset was renamed or removed; forgetting to call the registration code (e.g. a register_defaults()/import of the module that registers presets) before fetching.","solutions":["Read the available ids from the error message (or call list_preset_ids()) and use one of them.","Fix the typo / renamed id in your config.","If a custom preset is intended, register it first with register_preset(...), then call get_preset."],"exampleFix":"# before\nstage = MyStage.from_preset(\"accurat\")  # typo\n\n# after\nprint(MyStage.list_preset_ids())  # confirm valid ids\nstage = MyStage.from_preset(\"accurate\")","handlingStrategy":"validation","validationCode":"def preset_exists(stage_cls, preset_id: str) -> bool:\n    return preset_id in stage_cls.list_preset_ids()\n\nif not preset_exists(MyStage, pid):\n    raise ValueError(f\"unknown preset {pid}; valid: {MyStage.list_preset_ids()}\")","typeGuard":"def is_known_preset(stage_cls, preset_id: str) -> bool:\n    return preset_id in stage_cls.list_preset_ids()","tryCatchPattern":"try:\n    preset = MyStage.get_preset(pid)\nexcept KeyError as e:\n    candidates = difflib.get_close_matches(pid, MyStage.list_preset_ids(), n=1)\n    raise ValueError(f\"Unknown preset. Did you mean {candidates}?\") from e","preventionTips":["Resolve preset ids from list_preset_ids() instead of hardcoding strings.","Re-validate configured preset ids in a startup check after docling upgrades."],"tags":["preset","registry","lookup","stage-model","configuration"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}