OpenBB-finance/OpenBB · error · OpenBBError
Invalid URL '{url}'. Only PDF documents are supported.
Error message
Invalid URL '{url}'. Only PDF documents are supported. What it means
Companion guard in the same URL loop: each URL must end with .pdf (case-insensitive). The extractor only parses PDF documents, so any HTML page, direct-content URL, or file without a .pdf extension is rejected up front with an OpenBBError-wrapped ValueError.
Source
Thrown at openbb_platform/providers/government_us/openbb_government_us/models/weather_bulletin_download.py:71
**kwargs: Any,
) -> dict:
"""Extract the raw PDF content."""
# pylint: disable=import-outside-toplevel
from openbb_core.provider.utils.helpers import get_async_requests_session
results: dict = {}
urls = query.urls
# Verify that all URLs are going to be valid USDA URLs
for url in urls:
if not url.lower().startswith("https://esmis.nal.usda.gov/"):
raise OpenBBError(
ValueError(
f"Invalid URL '{url}'. Only URLs from 'esmis.nal.usda.gov' are supported."
)
)
if not url.lower().endswith(".pdf"):
raise OpenBBError(
ValueError(
f"Invalid URL '{url}'. Only PDF documents are supported."
)
)
try:
async with await get_async_requests_session() as session:
session._max_field_size = 32768 # pylint: disable=protected-access
for url in urls:
async with await session.get(url) as response:
if response.status != 200:
raise OpenBBError(
ValueError(
f"Failed to download document from {url}. Status code: {response.status}"
)
)
content_bytes = await response.read()View on GitHub (pinned to 3e071fcc2c)
Solutions
- Pass the direct PDF download links from esmis.nal.usda.gov (they end in .pdf).
- Get URLs programmatically from the weather_bulletin endpoint response, which returns the PDF links.
- If the site changed its URL scheme, update openbb-platform.
Example fix
# before urls=["https://esmis.nal.usda.gov/catalog/record/12345"] # after urls=["https://esmis.nal.usda.gov/catalog/download/12345/PDF/wwcb-2024.pdf"]
Defensive patterns
Strategy: validation
Validate before calling
def is_pdf_url(url: str) -> bool:
return url.lower().endswith(".pdf") Type guard
def is_pdf_download_url(u: str) -> bool is not None and isinstance(u, str) and u.lower().startswith("https://esmis.nal.usda.gov/") and u.lower().endswith(".pdf") Prevention
- Always pass the direct 'Download' link, not the catalog landing page.
- Run both URL guards (host + .pdf) before calling the download endpoint.
When it happens
Trigger: Passing a landing/abstract page URL (no .pdf), a .htm/.html link, or a download URL with query strings after the extension trimmed.
Common situations: Copying the catalog page URL instead of the 'Download' link; ESMIS links that route through a redirect without .pdf in the path.
Related errors
- Either 'content' or 'url' must be provided.
- Invalid URL reference provided
- Year must not be before 1974.
- Invalid year. Year cannot be in the future.
- Invalid URL '{url}'. Only URLs from 'esmis.nal.usda.gov' are
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/69f752975feac59e.
Report an issue: GitHub.