{"record":{"id":"9144eeb1cfddda3c","repo":"PaddlePaddle/PaddleOCR","slug":"unknown-provider-provider","errorCode":null,"errorMessage":"Unknown provider: {provider}","messagePattern":"Unknown provider: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mcp_server/paddleocr_mcp/__main__.py","lineNumber":219,"sourceCode":"            poll_timeout=float(args.aistudio_poll_timeout),\n        )\n    elif provider == InferenceProvider.QIANFAN.value:\n        return create_inference(\n            model=model,\n            provider=provider,\n            base_url=args.qianfan_base_url,\n            api_key=args.qianfan_api_key,\n            http_timeout=args.http_timeout,\n        )\n    elif provider == InferenceProvider.SELF_HOSTED.value:\n        return create_inference(\n            model=model,\n            provider=provider,\n            base_url=args.self_hosted_base_url,\n            http_timeout=args.http_timeout,\n        )\n    else:\n        raise ValueError(f\"Unknown provider: {provider}\")\n\n\nasync def async_main() -> None:\n    \"\"\"Asynchronous main entry point.\"\"\"\n    args = _parse_args()\n    _validate_args(args)\n\n    try:\n        model = resolve_model(args.model, args.ppocr_source)\n    except ValueError as e:\n        print(f\"Error: {e}\", file=sys.stderr)\n        sys.exit(2)\n\n    inference = _create_inference_from_args(args, model)\n\n    try:\n        await inference.start()\n","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/mcp_server/paddleocr_mcp/__main__.py#L201-L237","documentation":"ValueError from the paddleocr_mcp __main__ provider dispatch: after handling the appstore and self_hosted branches (and qianfan above), any other --provider value falls into the else and raises 'Unknown provider'. The printed message uses the raw provider string, and async_main catches ValueError, prints it, and exits with code 2.","triggerScenarios":"Starting the MCP server with --provider set to a value not in InferenceProvider (e.g. 'local', 'qianfan ' with whitespace, wrong casing like 'SelfHosted'); a typo on the CLI.","commonSituations":"CLI flags copied from outdated docs where provider names changed; env var supplying the provider with trailing newline/whitespace.","solutions":["Use one of the exact InferenceProvider values (e.g. appstore, qianfan, self_hosted) — check the enum in paddleocr_mcp for the authoritative list.","If the provider comes from an environment variable, strip it: os.environ[...].strip().","Check `--help` output of the mcp server for the allowed choices."],"exampleFix":"// before\npaddleocr-mcp --provider local\nError: Unknown provider: local\n\n// after\npaddleocr-mcp --provider self_hosted","handlingStrategy":"validation","validationCode":"from paddleocr_mcp import InferenceProvider  # or import from its selection/config module\n\ndef provider_valid(provider: str) -> bool:\n    return (provider or \"\").strip() in {p.value for p in InferenceProvider}","typeGuard":"from typing import Any\n\ndef is_known_provider(value: Any) -> bool:\n    if isinstance(value, InferenceProvider):\n        return True\n    return isinstance(value, str) and value.strip() in {\n        p.value for p in InferenceProvider\n    }","tryCatchPattern":"try:\n    create_provider(args)\nexcept ValueError as e:\n    if \"Unknown provider\" in str(e):\n        # exit code 2 already set by async_main; log allowed values for the operator\n        log.error(\"provider must be one of %s\", [p.value for p in InferenceProvider])\n    raise","preventionTips":["Source --provider from the InferenceProvider enum values in launcher scripts.","Strip() environment-derived provider strings before use.","Add a startup check that fails fast with the allowed list instead of relying on runtime dispatch."],"tags":["python","mcp","cli","provider","validation"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}