{"record":{"id":"ba63327adc34a237","repo":"OpenBB-finance/OpenBB","slug":"unsupported-document-format-file-must-be-pdf-or-h","errorCode":null,"errorMessage":"Unsupported document format. File must be PDF or HTM type -> {url}","messagePattern":"Unsupported document format\\. File must be PDF or HTM type -> (.+?)","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/federal_reserve/openbb_federal_reserve/router.py","lineNumber":73,"sourceCode":"        hostname = parsed_url.hostname or \"\"\n\n        if parsed_url.scheme != \"https\" or hostname not in {\n            \"www.federalreserve.gov\",\n            \"federalreserve.gov\",\n        }:\n            raise OpenBBError(\n                \"Invalid URL provided for download. Must be from federalreserve.gov -> \"\n                + url\n            )\n\n        is_pdf = url.lower().endswith(\".pdf\")\n\n        if (\n            not is_pdf\n            and not url.lower().endswith(\".htm\")\n            and not url.lower().endswith(\".html\")\n        ):\n            raise OpenBBError(\n                \"Unsupported document format. File must be PDF or HTM type -> \" + url\n            )\n\n        try:\n            response = make_request(url)\n            response.raise_for_status()\n            pdf = (\n                base64.b64encode(BytesIO(response.content).getvalue()).decode(\"utf-8\")\n                if isinstance(response.content, bytes)\n                else response.content\n            )\n            results.append(\n                {\n                    \"content\": pdf,\n                    \"data_format\": {\n                        \"data_type\": \"pdf\" if is_pdf else \"markdown\",\n                        \"filename\": url.split(\"/\")[-1],\n                    },","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/federal_reserve/openbb_federal_reserve/router.py#L55-L91","documentation":"Raised by the same router one check later: the URL passed the origin whitelist but its lowercase extension is neither .pdf, .htm, nor .html. The handler only knows how to extract/encode those document types, so anything else (e.g. .docx, .csv, extensionless) is rejected before the request is made.","triggerScenarios":"Passing a federalreserve.gov URL ending in .docx/.xls/.csv/.json or with no extension (many Fed publication links use query strings or extensionless paths); a URL with trailing punctuation or query params after a non-whitelisted extension.","commonSituations":"Copying links to Fed data files or press-release pages with unusual extensions; concatenating query parameters so the extension check no longer matches the end of the string.","solutions":["Link directly to the .pdf or .htm/.html version of the document (most Fed pubs have a /pubs/ PDF path).","Strip query strings/fragments so the URL ends with the recognized extension.","For other file types, fetch them with your own HTTP client instead of this router."],"exampleFix":"// before\nobb.federal_reserve.download(url=['https://www.federalreserve.gov/data/file.csv'])\n// after\nobb.federal_reserve.download(url=['https://www.federalreserve.gov/publications/files/report.pdf'])","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\npath = urlparse(url).path.lower()\nassert path.endswith(('.pdf', '.htm', '.html')), url","typeGuard":"def is_supported_doc(url: str) -> bool:\n    from urllib.parse import urlparse\n    return urlparse(url).path.lower().endswith(('.pdf', '.htm', '.html'))","tryCatchPattern":null,"preventionTips":["Link to the .pdf/.htm rendition of Fed documents","Drop query strings so extension checks see the true suffix"],"tags":["openbb","file-format","router","validation"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}