{"record":{"id":"dcdfdccda080a3a5","repo":"opendataloader-project/opendataloader-pdf","slug":"unsupported-format-format-r-supported-formats","errorCode":null,"errorMessage":"Unsupported format: {format!r}. Supported formats: {', '.join(ext_map)}","messagePattern":"Unsupported format: (.+?)\\. Supported formats: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/opendataloader-pdf-mcp/src/opendataloader_pdf_mcp/server.py","lineNumber":89,"sourceCode":"\n    Returns:\n        The converted content as text.\n    \"\"\"\n    input_file = Path(input_path).expanduser().resolve()\n    if not input_file.is_file():\n        raise FileNotFoundError(f\"Input file not found: {input_path}\")\n\n    # Determine output file extension from format\n    ext_map = {\n        \"json\": \".json\",\n        \"text\": \".txt\",\n        \"html\": \".html\",\n        \"markdown\": \".md\",\n        \"markdown-with-html\": \".md\",\n        \"markdown-with-images\": \".md\",\n    }\n    if format not in ext_map:\n        raise ValueError(\n            f\"Unsupported format: {format!r}. \"\n            f\"Supported formats: {', '.join(ext_map)}\"\n        )\n    ext = ext_map[format]\n\n    with tempfile.TemporaryDirectory() as tmp_dir:\n        kwargs: dict[str, Any] = {\n            \"input_path\": str(input_file),\n            \"output_dir\": tmp_dir,\n            \"format\": format,\n            \"quiet\": True,\n        }\n\n        # Only pass non-default values\n        if password is not None:\n            kwargs[\"password\"] = password\n        if pages is not None:\n            kwargs[\"pages\"] = pages","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/opendataloader-project/opendataloader-pdf/blob/a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8/python/opendataloader-pdf-mcp/src/opendataloader_pdf_mcp/server.py#L71-L107","documentation":"ValueError raised by the MCP convert tool when the format argument is not a key in ext_map. The accepted keys are json, text, html, markdown, markdown-with-html, markdown-with-images (the latter two are deprecated --format aliases per CLAUDE.md). The error message lists the valid set so the caller can self-correct.","triggerScenarios":"Calling the MCP convert tool with a format value outside the ext_map keys: e.g. 'pdf', 'csv', 'xml', 'markdown_html' (underscore instead of hyphen), or a typo like 'mar kdown'.","commonSituations":"An LLM/client invents a format not in the schema. A caller uses the deprecated markdown-with-images form without realizing it still works. Locale/normalization turns a hyphen into another character. A caller passes the image-output mode (off|embedded|external) into the format field by mistake.","solutions":["Use one of the listed formats: json, text, html, markdown (preferred); markdown-with-html / markdown-with-images still accepted but deprecated.","For HTML-in-markdown use format='markdown' plus the markdown-with-html flag, not a made-up format name.","If you need PDF output, note that tagged-pdf is an OUTPUT format handled separately — check the CLI options.json for the current set.","Validate the format against the tool's documented enum before calling."],"exampleFix":"# before: invented format\nconvert(input_path=pdf, format=\"pdf\")  # -> ValueError\n# after: valid format; HTML-in-markdown via the modifier flag\nconvert(input_path=pdf, format=\"markdown\", markdown_with_html=True)","handlingStrategy":"validation","validationCode":"SUPPORTED_FORMATS = {\"json\", \"text\", \"html\", \"markdown\", \"markdown-with-html\", \"markdown-with-images\"}\n\ndef validate_format(fmt: str) -> str:\n    if fmt not in SUPPORTED_FORMATS:\n        raise ValueError(f\"Unsupported format: {fmt!r}. Use one of {sorted(SUPPORTED_FORMATS)}\")\n    return fmt\n","typeGuard":"def is_supported_format(fmt: str) -> bool:\n    return fmt in {\"json\", \"text\", \"html\", \"markdown\", \"markdown-with-html\", \"markdown-with-images\"}","tryCatchPattern":"try:\n    result = convert(input_path=path, format=fmt)\nexcept ValueError as e:\n    if \"Unsupported format\" in str(e):\n        return {\"error\": str(e), \"formats\": sorted(SUPPORTED_FORMATS)}\n    raise","preventionTips":["Validate the format against the documented enum on the client before calling the MCP tool.","Prefer 'markdown' plus modifier flags over the deprecated markdown-with-html/markdown-with-images aliases.","Do not conflate the format field with the image-output mode (off|embedded|external)."],"tags":["mcp","format","validation","valueerror","python"],"backgroundTag":null,"analyzedSha":"a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8","analyzedAt":"2026-08-14T05:22:03.953Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}