{"record":{"id":"ab742d715e5e24d0","repo":"PaddlePaddle/PaddleOCR","slug":"invalid-engine-engine-supported-values-are-s","errorCode":null,"errorMessage":"Invalid engine: {engine}. Supported values are: {SUPPORTED_INFERENCE_ENGINE_LIST}.","messagePattern":"Invalid engine: (.+?)\\. Supported values are: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"paddleocr/_common_args.py","lineNumber":62,"sourceCode":"        \"use_tensorrt\": DEFAULT_USE_TENSORRT,\n        \"precision\": DEFAULT_PRECISION,\n        \"enable_mkldnn\": DEFAULT_ENABLE_MKLDNN,\n        \"mkldnn_cache_capacity\": DEFAULT_MKLDNN_CACHE_CAPACITY,\n        \"cpu_threads\": DEFAULT_CPU_THREADS,\n        \"enable_cinn\": DEFAULT_USE_CINN,\n    }\n\n    unknown_names = kwargs.keys() - default_vals.keys()\n    for name in unknown_names:\n        raise ValueError(f\"Unknown argument: {name}\")\n\n    kwargs = {**default_vals, **kwargs}\n\n    if (\n        kwargs[\"engine\"] is not None\n        and kwargs[\"engine\"] not in SUPPORTED_INFERENCE_ENGINE_LIST\n    ):\n        raise ValueError(\n            f\"Invalid engine: {kwargs['engine']}. Supported values are: {SUPPORTED_INFERENCE_ENGINE_LIST}.\"\n        )\n\n    if kwargs[\"precision\"] not in SUPPORTED_PRECISION_LIST:\n        raise ValueError(\n            f\"Invalid precision: {kwargs['precision']}. Supported values are: {SUPPORTED_PRECISION_LIST}.\"\n        )\n\n    kwargs[\"use_pptrt\"] = kwargs.pop(\"use_tensorrt\")\n    kwargs[\"pptrt_precision\"] = kwargs.pop(\"precision\")\n\n    return kwargs\n\n\ndef _build_paddle_static_engine_config(common_args, device_type):\n    cfg = {}\n    if device_type == \"gpu\":\n        if common_args[\"use_pptrt\"]:","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_common_args.py#L44-L80","documentation":"ValueError raised by parse_common_args when engine is not None and not one of SUPPORTED_INFERENCE_ENGINE_LIST: 'paddle', 'paddle_static', 'paddle_dynamic', 'transformers', 'onnxruntime'. This validates the inference backend selection before any model loads.","triggerScenarios":"PaddleOCR(engine='onnx') instead of 'onnxruntime'; engine='paddle_inference'; passing an engine string from a different library's vocabulary.","commonSituations":"Assuming short names work; version drift if the supported engine list changed; configuring engines without checking the constant.","solutions":["Use one of: paddle, paddle_static, paddle_dynamic, transformers, onnxruntime","Import and assert against the constant: from paddleocr._common_args import SUPPORTED_INFERENCE_ENGINE_LIST","Leave engine=None to use the default backend"],"exampleFix":"# before\nocr = PaddleOCR(engine='onnx')\n# after\nocr = PaddleOCR(engine='onnxruntime')","handlingStrategy":"validation","validationCode":"from paddleocr._common_args import SUPPORTED_INFERENCE_ENGINE_LIST\n\nif engine is not None and engine not in SUPPORTED_INFERENCE_ENGINE_LIST:\n    raise ValueError(f'pick engine from {SUPPORTED_INFERENCE_ENGINE_LIST}')","typeGuard":"from typing import Literal\n\nEngine = Literal['paddle','paddle_static','paddle_dynamic','transformers','onnxruntime']\n\ndef is_engine(v: str) -> 'TypeGuard[Engine]':\n    return v in ('paddle','paddle_static','paddle_dynamic','transformers','onnxruntime')","tryCatchPattern":null,"preventionTips":["Read SUPPORTED_INFERENCE_ENGINE_LIST at startup if you offer engine selection to users","Treat engine strings as an enum, not free text"],"tags":["validation","configuration","inference-engine"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}