{"record":{"id":"69f752975feac59e","repo":"OpenBB-finance/OpenBB","slug":"invalid-url-url-only-pdf-documents-are-suppor","errorCode":null,"errorMessage":"Invalid URL '{url}'. Only PDF documents are supported.","messagePattern":"Invalid URL '(.+?)'\\. Only PDF documents are supported\\.","errorType":"validation","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/government_us/openbb_government_us/models/weather_bulletin_download.py","lineNumber":71,"sourceCode":"        **kwargs: Any,\n    ) -> dict:\n        \"\"\"Extract the raw PDF content.\"\"\"\n        # pylint: disable=import-outside-toplevel\n        from openbb_core.provider.utils.helpers import get_async_requests_session\n\n        results: dict = {}\n        urls = query.urls\n\n        # Verify that all URLs are going to be valid USDA URLs\n        for url in urls:\n            if not url.lower().startswith(\"https://esmis.nal.usda.gov/\"):\n                raise OpenBBError(\n                    ValueError(\n                        f\"Invalid URL '{url}'. Only URLs from 'esmis.nal.usda.gov' are supported.\"\n                    )\n                )\n            if not url.lower().endswith(\".pdf\"):\n                raise OpenBBError(\n                    ValueError(\n                        f\"Invalid URL '{url}'. Only PDF documents are supported.\"\n                    )\n                )\n\n        try:\n            async with await get_async_requests_session() as session:\n                session._max_field_size = 32768  # pylint: disable=protected-access\n\n                for url in urls:\n                    async with await session.get(url) as response:\n                        if response.status != 200:\n                            raise OpenBBError(\n                                ValueError(\n                                    f\"Failed to download document from {url}. Status code: {response.status}\"\n                                )\n                            )\n                        content_bytes = await response.read()","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/government_us/openbb_government_us/models/weather_bulletin_download.py#L53-L89","documentation":"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.","triggerScenarios":"Passing a landing/abstract page URL (no .pdf), a .htm/.html link, or a download URL with query strings after the extension trimmed.","commonSituations":"Copying the catalog page URL instead of the 'Download' link; ESMIS links that route through a redirect without .pdf in the path.","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."],"exampleFix":"# before\nurls=[\"https://esmis.nal.usda.gov/catalog/record/12345\"]\n\n# after\nurls=[\"https://esmis.nal.usda.gov/catalog/download/12345/PDF/wwcb-2024.pdf\"]","handlingStrategy":"validation","validationCode":"def is_pdf_url(url: str) -> bool:\n    return url.lower().endswith(\".pdf\")","typeGuard":"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\")","tryCatchPattern":null,"preventionTips":["Always pass the direct 'Download' link, not the catalog landing page.","Run both URL guards (host + .pdf) before calling the download endpoint."],"tags":["validation","pdf","weather-bulletin"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}