docling-project/docling · error · ValueError

Unsupported engine type {preset.default_engine_type} for pre

Error message

Unsupported engine type {preset.default_engine_type} for presets

What it means

In ObjectDetectionStage.from_preset, if engine_options is None and the preset's default_engine_type matches none of ONNXRUNTIME, TRANSFORMERS, or API_KSERVE_V2, a ValueError is raised stating the engine type is unsupported. This is a defensive exhaustiveness check: it normally indicates a new enum value added to ObjectDetectionEngineType without a corresponding branch here, or a corrupt/custom preset definition.

Source

Thrown at docling/datamodel/stage_model_specs.py:785

            TransformersObjectDetectionEngineOptions,
        )

        preset = cls.get_preset(preset_id)

        if engine_options is None:
            if preset.default_engine_type == ObjectDetectionEngineType.ONNXRUNTIME:
                engine_options = OnnxRuntimeObjectDetectionEngineOptions()
            elif preset.default_engine_type == ObjectDetectionEngineType.TRANSFORMERS:
                engine_options = TransformersObjectDetectionEngineOptions()
            elif preset.default_engine_type == ObjectDetectionEngineType.API_KSERVE_V2:
                raise ValueError(
                    f"Preset '{preset_id}' uses API_KSERVE_V2 engine which requires explicit "
                    "engine_options with a 'url' parameter. Please provide "
                    "engine_options=ApiKserveV2ObjectDetectionEngineOptions(url='...') "
                    "when calling from_preset()."
                )
            else:
                raise ValueError(
                    f"Unsupported engine type {preset.default_engine_type} for presets"
                )

        instance = cls(  # type: ignore[call-arg]
            model_spec=preset.model_spec,
            engine_options=engine_options,
            **preset.stage_options,
        )

        for key, value in overrides.items():
            setattr(instance, key, value)

        return instance


class ImageClassificationStagePreset(BaseModel):
    """Preset definition for image classification-powered stages."""

View on GitHub (pinned to 61d76f1ff3)

Solutions

  1. Pass explicit engine_options matching your engine so no default branch is needed.
  2. If registering the preset yourself, set default_engine_type to ONNXRUNTIME, TRANSFORMERS, or API_KSERVE_V2.
  3. If a legitimate new engine value hits this, report it upstream — the branch list is missing a case.

Example fix

# before
stage = ObjectDetectionStage.from_preset("custom_preset")  # preset has exotic engine

# after
stage = ObjectDetectionStage.from_preset(
    "custom_preset",
    engine_options=OnnxRuntimeObjectDetectionEngineOptions(),
)
Defensive patterns

Strategy: try-catch

Validate before calling

SUPPORTED_OD_ENGINES = {ObjectDetectionEngineType.ONNXRUNTIME, ObjectDetectionEngineType.TRANSFORMERS, ObjectDetectionEngineType.API_KSERVE_V2}
if engine_options is None and preset.default_engine_type not in SUPPORTED_OD_ENGINES:
    engine_options = OnnxRuntimeObjectDetectionEngineOptions()  # explicit safe choice

Try / catch

try:
    stage = ObjectDetectionStage.from_preset(pid)
except ValueError as e:
    if "Unsupported engine type" in str(e):
        stage = ObjectDetectionStage.from_preset(pid, engine_options=OnnxRuntimeObjectDetectionEngineOptions())
    else:
        raise

Prevention

When it happens

Trigger: A preset registered with default_engine_type set to a value outside the three handled enum members, then from_preset(preset_id) called without engine_options. Users who pass engine_options explicitly bypass all branches and never hit this.

Common situations: Custom presets built with a newly added or experimental engine enum value; version skew between docling packages where the enum knows more values than from_preset handles.

Related errors


AI-assisted analysis of docling-project/docling@61d76f1ff3 (2026-08-14). Data as JSON: /api/errors/014c6140abe0646f. Report an issue: GitHub.