OpenBB-finance/OpenBB · error · OpenBBError

Unsupported document format. File must be PDF or HTM type ->

Error message

Unsupported document format. File must be PDF or HTM type -> {url}

What it means

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.

Source

Thrown at openbb_platform/providers/federal_reserve/openbb_federal_reserve/router.py:73

        hostname = parsed_url.hostname or ""

        if parsed_url.scheme != "https" or hostname not in {
            "www.federalreserve.gov",
            "federalreserve.gov",
        }:
            raise OpenBBError(
                "Invalid URL provided for download. Must be from federalreserve.gov -> "
                + url
            )

        is_pdf = url.lower().endswith(".pdf")

        if (
            not is_pdf
            and not url.lower().endswith(".htm")
            and not url.lower().endswith(".html")
        ):
            raise OpenBBError(
                "Unsupported document format. File must be PDF or HTM type -> " + url
            )

        try:
            response = make_request(url)
            response.raise_for_status()
            pdf = (
                base64.b64encode(BytesIO(response.content).getvalue()).decode("utf-8")
                if isinstance(response.content, bytes)
                else response.content
            )
            results.append(
                {
                    "content": pdf,
                    "data_format": {
                        "data_type": "pdf" if is_pdf else "markdown",
                        "filename": url.split("/")[-1],
                    },

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Link directly to the .pdf or .htm/.html version of the document (most Fed pubs have a /pubs/ PDF path).
  2. Strip query strings/fragments so the URL ends with the recognized extension.
  3. For other file types, fetch them with your own HTTP client instead of this router.

Example fix

// before
obb.federal_reserve.download(url=['https://www.federalreserve.gov/data/file.csv'])
// after
obb.federal_reserve.download(url=['https://www.federalreserve.gov/publications/files/report.pdf'])
Defensive patterns

Strategy: validation

Validate before calling

from urllib.parse import urlparse
path = urlparse(url).path.lower()
assert path.endswith(('.pdf', '.htm', '.html')), url

Type guard

def is_supported_doc(url: str) -> bool:
    from urllib.parse import urlparse
    return urlparse(url).path.lower().endswith(('.pdf', '.htm', '.html'))

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/ba63327adc34a237. Report an issue: GitHub.